2017-01-15 23:23:09 +00:00
|
|
|
package service
|
2021-09-29 16:13:23 +00:00
|
|
|
|
2022-02-28 12:34:44 +00:00
|
|
|
type alreadyExistsError struct{}
|
|
|
|
|
|
|
|
func (a alreadyExistsError) Error() string {
|
|
|
|
return "Entity already exists"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a alreadyExistsError) IsExists() bool {
|
|
|
|
return true
|
|
|
|
}
|
2022-06-21 13:04:50 +00:00
|
|
|
|
2022-07-18 16:44:30 +00:00
|
|
|
type notFoundError struct{}
|
|
|
|
|
|
|
|
func (e notFoundError) Error() string {
|
|
|
|
return "not found"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e notFoundError) IsNotFound() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2022-06-21 13:04:50 +00:00
|
|
|
// ssoErrCode defines a code for the type of SSO error that occurred. This is
|
|
|
|
// used to indicate to the frontend why the SSO login attempt failed so that
|
|
|
|
// it can provide a helpful and appropriate error message.
|
|
|
|
type ssoErrCode string
|
|
|
|
|
|
|
|
// List of valid SSO error codes.
|
|
|
|
const (
|
|
|
|
ssoOtherError ssoErrCode = "error"
|
|
|
|
ssoOrgDisabled ssoErrCode = "org_disabled"
|
|
|
|
ssoAccountDisabled ssoErrCode = "account_disabled"
|
|
|
|
ssoAccountInvalid ssoErrCode = "account_invalid"
|
|
|
|
)
|
|
|
|
|
2022-10-05 16:42:45 +00:00
|
|
|
// ssoError is an error that occurs during the single sign-on flow. Its code
|
2022-06-21 13:04:50 +00:00
|
|
|
// indicates the type of error.
|
|
|
|
type ssoError struct {
|
|
|
|
err error
|
|
|
|
code ssoErrCode
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ssoError) Error() string {
|
|
|
|
return string(e.code) + ": " + e.err.Error()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e ssoError) Unwrap() error {
|
|
|
|
return e.err
|
|
|
|
}
|