Documentation ¶
Index ¶
Constants ¶
View Source
const ( UnknownError = 10000 BadRequest = 10001 TooManyRequests = 10002 // Rate limit )
General errors
View Source
const ( UserAlreadyExistsError = 10101 UserNotFound = 10102 UserNotVerifiedError = 10103 UserLicenseExpiredError = 10104 UserEmailNotFound = 10105 UserIncorrectPassword = 10106 )
User
View Source
const ( UserAlreadyVerifiedError = 10201 InvalidTokenError = 10202 )
Email verification
Variables ¶
View Source
var ErrorMapping map[int]CustomErrWithCode = map[int]CustomErrWithCode{ BadRequest: { StatusCode: http.StatusBadRequest, Code: BadRequest, Message: "Invalid request", }, TooManyRequests: { StatusCode: http.StatusTooManyRequests, Code: TooManyRequests, Message: "Too many requests sent, try again later", }, Unauthorized: { StatusCode: http.StatusUnauthorized, Code: Unauthorized, Message: "Unauthorized", }, UserAlreadyExistsError: { StatusCode: http.StatusConflict, Code: UserAlreadyExistsError, Message: "User with matching email already exists", }, UserNotFound: { StatusCode: http.StatusNotFound, Code: UserNotFound, Message: "User not found", }, UserNotVerifiedError: { StatusCode: http.StatusForbidden, Code: UserNotVerifiedError, Message: "Account email is not verified", }, UserLicenseExpiredError: { StatusCode: http.StatusMethodNotAllowed, Code: UserLicenseExpiredError, Message: "License expired", }, UserEmailNotFound: { StatusCode: http.StatusNotFound, Code: UserEmailNotFound, Message: "An account with the provided email cannot be found", }, UserIncorrectPassword: { StatusCode: http.StatusUnauthorized, Code: UserIncorrectPassword, Message: "Incorrect password", }, UserAlreadyVerifiedError: { StatusCode: http.StatusMethodNotAllowed, Code: UserAlreadyVerifiedError, Message: "Failed to send verification email: user already verified", }, InvalidTokenError: { StatusCode: http.StatusUnauthorized, Code: InvalidTokenError, Message: "Invalid token", }, }
Functions ¶
This section is empty.
Types ¶
type CustomErrWithCode ¶
func NewError ¶
func NewError(code int) CustomErrWithCode
func (CustomErrWithCode) Error ¶
func (c CustomErrWithCode) Error() string
Click to show internal directories.
Click to hide internal directories.