apierrors

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode = string
const (
	// ErrorCodeUnknown should not be used directly, it only indicates a failure in the error handling system in such a way that an error code was not assigned properly.
	ErrorCodeUnknown ErrorCode = "unknown"

	// ErrorCodeUnexpectedFailure signals an unexpected failure such as a 500 Internal Server Error.
	ErrorCodeUnexpectedFailure ErrorCode = "unexpected_failure"

	ErrorCodeValidationFailed                  ErrorCode = "validation_failed"
	ErrorCodeBadJSON                           ErrorCode = "bad_json"
	ErrorCodeEmailExists                       ErrorCode = "email_exists"
	ErrorCodePhoneExists                       ErrorCode = "phone_exists"
	ErrorCodeBadJWT                            ErrorCode = "bad_jwt"
	ErrorCodeNotAdmin                          ErrorCode = "not_admin"
	ErrorCodeNoAuthorization                   ErrorCode = "no_authorization"
	ErrorCodeUserNotFound                      ErrorCode = "user_not_found"
	ErrorCodeSessionNotFound                   ErrorCode = "session_not_found"
	ErrorCodeSessionExpired                    ErrorCode = "session_expired"
	ErrorCodeRefreshTokenNotFound              ErrorCode = "refresh_token_not_found"
	ErrorCodeRefreshTokenAlreadyUsed           ErrorCode = "refresh_token_already_used"
	ErrorCodeFlowStateNotFound                 ErrorCode = "flow_state_not_found"
	ErrorCodeFlowStateExpired                  ErrorCode = "flow_state_expired"
	ErrorCodeOAuthClientStateNotFound          ErrorCode = "oauth_client_state_not_found"
	ErrorCodeOAuthClientStateExpired           ErrorCode = "oauth_client_state_expired"
	ErrorCodeOAuthInvalidState                 ErrorCode = "oauth_invalid_state"
	ErrorCodeSignupDisabled                    ErrorCode = "signup_disabled"
	ErrorCodeUserBanned                        ErrorCode = "user_banned"
	ErrorCodeProviderEmailNeedsVerification    ErrorCode = "provider_email_needs_verification"
	ErrorCodeInviteNotFound                    ErrorCode = "invite_not_found"
	ErrorCodeBadOAuthState                     ErrorCode = "bad_oauth_state"
	ErrorCodeBadOAuthCallback                  ErrorCode = "bad_oauth_callback"
	ErrorCodeOAuthProviderNotSupported         ErrorCode = "oauth_provider_not_supported"
	ErrorCodeUnexpectedAudience                ErrorCode = "unexpected_audience"
	ErrorCodeSingleIdentityNotDeletable        ErrorCode = "single_identity_not_deletable"
	ErrorCodeEmailConflictIdentityNotDeletable ErrorCode = "email_conflict_identity_not_deletable"
	ErrorCodeIdentityAlreadyExists             ErrorCode = "identity_already_exists"
	ErrorCodeEmailProviderDisabled             ErrorCode = "email_provider_disabled"
	ErrorCodePhoneProviderDisabled             ErrorCode = "phone_provider_disabled"
	ErrorCodeTooManyEnrolledMFAFactors         ErrorCode = "too_many_enrolled_mfa_factors"
	ErrorCodeMFAFactorNameConflict             ErrorCode = "mfa_factor_name_conflict"
	ErrorCodeMFAFactorNotFound                 ErrorCode = "mfa_factor_not_found"
	ErrorCodeMFAIPAddressMismatch              ErrorCode = "mfa_ip_address_mismatch"
	ErrorCodeMFAChallengeExpired               ErrorCode = "mfa_challenge_expired"
	ErrorCodeMFAVerificationFailed             ErrorCode = "mfa_verification_failed"
	ErrorCodeMFAVerificationRejected           ErrorCode = "mfa_verification_rejected"
	ErrorCodeInsufficientAAL                   ErrorCode = "insufficient_aal"
	ErrorCodeCaptchaFailed                     ErrorCode = "captcha_failed"
	ErrorCodeSAMLProviderDisabled              ErrorCode = "saml_provider_disabled"
	ErrorCodeManualLinkingDisabled             ErrorCode = "manual_linking_disabled"
	ErrorCodeSMSSendFailed                     ErrorCode = "sms_send_failed"
	ErrorCodeEmailNotConfirmed                 ErrorCode = "email_not_confirmed"
	ErrorCodePhoneNotConfirmed                 ErrorCode = "phone_not_confirmed"
	ErrorCodeSAMLRelayStateNotFound            ErrorCode = "saml_relay_state_not_found"
	ErrorCodeSAMLRelayStateExpired             ErrorCode = "saml_relay_state_expired"
	ErrorCodeSAMLIdPNotFound                   ErrorCode = "saml_idp_not_found"
	ErrorCodeSAMLAssertionNoUserID             ErrorCode = "saml_assertion_no_user_id"
	ErrorCodeSAMLAssertionNoEmail              ErrorCode = "saml_assertion_no_email"
	ErrorCodeUserAlreadyExists                 ErrorCode = "user_already_exists"
	ErrorCodeSSOProviderNotFound               ErrorCode = "sso_provider_not_found"
	ErrorCodeSSOProviderDisabled               ErrorCode = "sso_provider_disabled"
	ErrorCodeSAMLMetadataFetchFailed           ErrorCode = "saml_metadata_fetch_failed"
	ErrorCodeSAMLIdPAlreadyExists              ErrorCode = "saml_idp_already_exists"
	ErrorCodeSSODomainAlreadyExists            ErrorCode = "sso_domain_already_exists"
	ErrorCodeSAMLEntityIDMismatch              ErrorCode = "saml_entity_id_mismatch"
	ErrorCodeConflict                          ErrorCode = "conflict"
	ErrorCodeProviderDisabled                  ErrorCode = "provider_disabled"
	ErrorCodeUserSSOManaged                    ErrorCode = "user_sso_managed"
	ErrorCodeReauthenticationNeeded            ErrorCode = "reauthentication_needed"
	ErrorCodeSamePassword                      ErrorCode = "same_password"
	ErrorCodeReauthenticationNotValid          ErrorCode = "reauthentication_not_valid"
	ErrorCodeCurrentPasswordMismatch           ErrorCode = "current_password_invalid"
	ErrorCodeCurrentPasswordRequired           ErrorCode = "current_password_required"
	ErrorCodeOTPExpired                        ErrorCode = "otp_expired"
	ErrorCodeOTPDisabled                       ErrorCode = "otp_disabled"
	ErrorCodeIdentityNotFound                  ErrorCode = "identity_not_found"
	ErrorCodeWeakPassword                      ErrorCode = "weak_password"
	ErrorCodeOverRequestRateLimit              ErrorCode = "over_request_rate_limit"
	ErrorCodeOverEmailSendRateLimit            ErrorCode = "over_email_send_rate_limit"
	ErrorCodeOverSMSSendRateLimit              ErrorCode = "over_sms_send_rate_limit"
	ErrorCodeBadCodeVerifier                   ErrorCode = "bad_code_verifier"
	ErrorCodeAnonymousProviderDisabled         ErrorCode = "anonymous_provider_disabled"
	ErrorCodeHookTimeout                       ErrorCode = "hook_timeout"
	ErrorCodeHookTimeoutAfterRetry             ErrorCode = "hook_timeout_after_retry"
	ErrorCodeHookPayloadOverSizeLimit          ErrorCode = "hook_payload_over_size_limit"
	ErrorCodeHookPayloadInvalidContentType     ErrorCode = "hook_payload_invalid_content_type"
	ErrorCodeRequestTimeout                    ErrorCode = "request_timeout"
	ErrorCodeMFAPhoneEnrollDisabled            ErrorCode = "mfa_phone_enroll_not_enabled"
	ErrorCodeMFAPhoneVerifyDisabled            ErrorCode = "mfa_phone_verify_not_enabled"
	ErrorCodeMFATOTPEnrollDisabled             ErrorCode = "mfa_totp_enroll_not_enabled"
	ErrorCodeMFATOTPVerifyDisabled             ErrorCode = "mfa_totp_verify_not_enabled"
	ErrorCodeMFAWebAuthnEnrollDisabled         ErrorCode = "mfa_webauthn_enroll_not_enabled"
	ErrorCodeMFAWebAuthnVerifyDisabled         ErrorCode = "mfa_webauthn_verify_not_enabled"
	ErrorCodeMFAVerifiedFactorExists           ErrorCode = "mfa_verified_factor_exists"
	//#nosec G101 -- Not a secret value.
	ErrorCodeInvalidCredentials                     ErrorCode = "invalid_credentials"
	ErrorCodeEmailAddressNotAuthorized              ErrorCode = "email_address_not_authorized"
	ErrorCodeEmailAddressInvalid                    ErrorCode = "email_address_invalid"
	ErrorCodeWeb3ProviderDisabled                   ErrorCode = "web3_provider_disabled"
	ErrorCodeWeb3UnsupportedChain                   ErrorCode = "web3_unsupported_chain"
	ErrorCodeOAuthDynamicClientRegistrationDisabled ErrorCode = "oauth_dynamic_client_registration_disabled"
	ErrorCodeEmailAddressNotProvided                ErrorCode = "email_address_not_provided"
	ErrorCodeFeatureDisabled                        ErrorCode = "feature_disabled"

	ErrorCodeOAuthClientNotFound        ErrorCode = "oauth_client_not_found"
	ErrorCodeOAuthAuthorizationNotFound ErrorCode = "oauth_authorization_not_found"
	ErrorCodeOAuthConsentNotFound       ErrorCode = "oauth_consent_not_found"

	ErrorCodeRequestEntityTooLarge ErrorCode = "request_entity_too_large"

	ErrorCodeCustomProviderNotFound  ErrorCode = "custom_provider_not_found"
	ErrorCodeOverCustomProviderQuota ErrorCode = "over_custom_provider_quota"

	// Passkey feature-level errors
	ErrorCodePasskeyDisabled ErrorCode = "passkey_disabled"
	ErrorCodeTooManyPasskeys ErrorCode = "too_many_passkeys"

	// WebAuthn protocol-level errors (shared between passkeys and MFA WebAuthn)
	ErrorCodeWebAuthnCredentialNotFound ErrorCode = "webauthn_credential_not_found" // #nosec G101 -- not a credential
	ErrorCodeWebAuthnChallengeNotFound  ErrorCode = "webauthn_challenge_not_found"
	ErrorCodeWebAuthnChallengeExpired   ErrorCode = "webauthn_challenge_expired"
	ErrorCodeWebAuthnVerificationFailed ErrorCode = "webauthn_verification_failed"
	ErrorCodeWebAuthnCredentialExists   ErrorCode = "webauthn_credential_exists" // #nosec G101 -- not a credential
)

type HTTPError

type HTTPError struct {
	HTTPStatus      int    `json:"code"`                 // do not rename the JSON tags!
	ErrorCode       string `json:"error_code,omitempty"` // do not rename the JSON tags!
	Message         string `json:"msg"`                  // do not rename the JSON tags!
	InternalError   error  `json:"-"`
	InternalMessage string `json:"-"`
	ErrorID         string `json:"error_id,omitempty"`
}

HTTPError is an error with a message and an HTTP status code.

func NewBadRequestError

func NewBadRequestError(errorCode ErrorCode, fmtString string, args ...any) *HTTPError

func NewConflictError

func NewConflictError(fmtString string, args ...any) *HTTPError

func NewForbiddenError

func NewForbiddenError(errorCode ErrorCode, fmtString string, args ...any) *HTTPError

func NewHTTPError

func NewHTTPError(httpStatus int, errorCode ErrorCode, fmtString string, args ...any) *HTTPError

func NewInternalServerError

func NewInternalServerError(fmtString string, args ...any) *HTTPError

func NewNotFoundError

func NewNotFoundError(errorCode ErrorCode, fmtString string, args ...any) *HTTPError

func NewTooManyRequestsError

func NewTooManyRequestsError(errorCode ErrorCode, fmtString string, args ...any) *HTTPError

func NewUnprocessableEntityError

func NewUnprocessableEntityError(errorCode ErrorCode, fmtString string, args ...any) *HTTPError

func (*HTTPError) Cause

func (e *HTTPError) Cause() error

Cause returns the root cause error

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Is

func (e *HTTPError) Is(target error) bool

func (*HTTPError) WithInternalError

func (e *HTTPError) WithInternalError(err error) *HTTPError

WithInternalError adds internal error information to the error

func (*HTTPError) WithInternalMessage

func (e *HTTPError) WithInternalMessage(fmtString string, args ...any) *HTTPError

WithInternalMessage adds internal message information to the error

type OAuthError

type OAuthError struct {
	Err             string `json:"error"`
	Description     string `json:"error_description,omitempty"`
	InternalError   error  `json:"-"`
	InternalMessage string `json:"-"`
}

OAuthError is the JSON handler for OAuth2 error responses

func NewOAuthError

func NewOAuthError(err string, description string) *OAuthError

func (*OAuthError) Cause

func (e *OAuthError) Cause() error

Cause returns the root cause error

func (*OAuthError) Error

func (e *OAuthError) Error() string

func (*OAuthError) WithInternalError

func (e *OAuthError) WithInternalError(err error) *OAuthError

WithInternalError adds internal error information to the error

func (*OAuthError) WithInternalMessage

func (e *OAuthError) WithInternalMessage(fmtString string, args ...any) *OAuthError

WithInternalMessage adds internal message information to the error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL