errors

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success             = New(http.StatusOK, 0, "success")
	ErrInternalServer   = New(http.StatusInternalServerError, 10001, "internal server error")
	ErrInvalidParams    = New(http.StatusBadRequest, 10002, "invalid parameters")
	ErrUnauthorized     = New(http.StatusUnauthorized, 10003, "unauthorized")
	ErrNotFound         = New(http.StatusNotFound, 10004, "resource not found")
	ErrMethodNotAllowed = New(http.StatusMethodNotAllowed, 10005, "method not allowed")
	ErrTooManyRequests  = New(http.StatusTooManyRequests, 10006, "too many requests")

	// Auth Errors
	ErrUserNotFound       = New(http.StatusNotFound, 20001, "user not found")
	ErrPasswordIncorrect  = New(http.StatusUnauthorized, 20002, "password incorrect")
	ErrTokenInvalid       = New(http.StatusUnauthorized, 20003, "token invalid")
	ErrTokenExpired       = New(http.StatusUnauthorized, 20004, "token expired")
	ErrUserAlreadyExists  = New(409, 20409, "User already exists")
	ErrInvalidCredentials = New(401, 20401, "Invalid credentials")
	ErrMFARequired        = New(403, 20403, "MFA required")
	ErrPasswordExpired    = New(403, 20404, "Password expired")
	ErrForbidden          = New(http.StatusForbidden, 10007, "forbidden")
)

Common Errors

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode interface {
	HTTPStatus() int
	BusinessCode() int
	Message() string
	Error() string // To satisfy standard error interface
}

ErrorCode is the interface for business errors

func New

func New(httpStatus, businessCode int, message string) ErrorCode

New creates a new custom error

Jump to

Keyboard shortcuts

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