errors

package
v0.0.0-...-db4338a Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// User-related errors
	ErrStatusNotFound     = "NOT_FOUND"
	ErrUserNotFound       = "USER_NOT_FOUND"
	ErrInvalidCredentials = "INVALID_CREDENTIALS"
	ErrInvalidUsername    = "INVALID_USERNAME_FORMAT"
	ErrWeakPassword       = "WEAK_PASSWORD"
	ErrEmailExists        = "EMAIL_ALREADY_EXISTS"
	ErrInvalidEmail       = "INVALID_EMAIL_FORMAT"

	// Backend errors
	ErrDBError         = "DB_ERROR"
	ErrValidationError = "VALIDATION_ERROR"

	// General errors
	ErrBadRequest          = "BAD_REQUEST"
	ErrConflict            = "CONFLICT_DETECTED"
	ErrOrderStatusNotFound = "ORDER_STATUS_NOT_FOUND"

	// Authentication & Authorization errors
	ErrUnauthorized   = "UNAUTHORIZED"
	ErrForbidden      = "FORBIDDEN"
	ErrInternalServer = "INTERNAL_SERVER_ERROR"
)

Variables

This section is empty.

Functions

func ClientError

func ClientError(w http.ResponseWriter, status int)

func NotFound

func NotFound(w http.ResponseWriter)

func ServerError

func ServerError(w http.ResponseWriter, err error)

Types

type CustomError

type CustomError struct {
	Code    string
	Message string
	Err     error
	Stack   string
}

func DBError

func DBError(err error, message string) *CustomError

func Forbidden

func Forbidden(message string) *CustomError

func InternalServerError

func InternalServerError(message string) *CustomError

func New

func New(code, message string) *CustomError

func StatusNotFound

func StatusNotFound(message string) *CustomError

func UnauthorizedError

func UnauthorizedError(message string) *CustomError

func UserNotFound

func UserNotFound(message string) *CustomError

func ValidationError

func ValidationError(message string) *CustomError

func Wrap

func Wrap(err error, code, message string) *CustomError

func (*CustomError) Error

func (e *CustomError) Error() string

func (*CustomError) UnWrap

func (e *CustomError) UnWrap() error

Jump to

Keyboard shortcuts

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