diff --git a/pkg/models/error.go b/pkg/models/error.go index 97e767377..7ec5b6ec4 100644 --- a/pkg/models/error.go +++ b/pkg/models/error.go @@ -1265,6 +1265,54 @@ func (err ErrOIDCTeamsDoNotExistForUser) HTTPError() web.HTTPError { return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No Teams with property oidcId could be found for User."} } +// ErrOIDCTeamDoesNotExist represents an error where a team with specified name and specified oidcId property does not exist +type ErrOIDCTeamDoesNotExist struct { + OidcID string + Name string +} + +// IsErrOIDCTeamDoesNotExist checks if an error is ErrOIDCTeamDoesNotExist. +func IsErrOIDCTeamDoesNotExist(err error) bool { + _, ok := err.(ErrOIDCTeamDoesNotExist) + return ok +} + +// ErrTeamDoesNotExist represents an error where a team does not exist +func (err ErrOIDCTeamDoesNotExist) Error() string { + return fmt.Sprintf("No Team with that name and valid property oidcId could be found [Team Name: %v] [OidcId : %v] ", err.Name, err.OidcID) +} + +// ErrCodeTeamDoesNotExist holds the unique world-error code of this error +const ErrCodeOIDCTeamDoesNotExist = 6008 + +// HTTPError holds the http error description +func (err ErrOIDCTeamDoesNotExist) HTTPError() web.HTTPError { + return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No Team with that name and valid property oidcId could be found."} +} + +// ErrOIDCTeamsDoNotExistForUser represents an error where an oidcTeam does not exist for the user +type ErrOIDCTeamsDoNotExistForUser struct { + UserID int64 +} + +// IsErrOIDCTeamsDoNotExistForUser checks if an error is ErrOIDCTeamsDoNotExistForUser. +func IsErrOIDCTeamsDoNotExistForUser(err error) bool { + _, ok := err.(ErrOIDCTeamsDoNotExistForUser) + return ok +} + +func (err ErrOIDCTeamsDoNotExistForUser) Error() string { + return fmt.Sprintf("No Teams with property oidcId could be found for User [User ID: %d]", err.UserID) +} + +// ErrCodeTeamDoesNotExist holds the unique world-error code of this error +const ErrCodeOIDCTeamsDoNotExistForUser = 6009 + +// HTTPError holds the http error description +func (err ErrOIDCTeamsDoNotExistForUser) HTTPError() web.HTTPError { + return web.HTTPError{HTTPCode: http.StatusNotFound, Code: ErrCodeTeamDoesNotExist, Message: "No Teams with property oidcId could be found for User."} +} + // ==================== // User <-> Project errors // ====================