resperror

package
v0.0.0-...-f06a132 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnknownError    = 10000
	BadRequest      = 10001
	TooManyRequests = 10002 // Rate limit
	Unauthorized    = 10003
)

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

type CustomErrWithCode struct {
	Code       int
	Message    string
	StatusCode int
}

func NewError

func NewError(code int) CustomErrWithCode

func (CustomErrWithCode) Error

func (c CustomErrWithCode) Error() string

Jump to

Keyboard shortcuts

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