apperr

package
v0.0.0-...-efe0c35 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStatusCode

func IsStatusCode(err error, statusCode StatusCode) bool

IsStatusCode checks if error is AppError and status code is statusCode

Types

type AppError

type AppError interface {
	error
	StatusCode() StatusCode
	HTTPStatusCode() int
}

AppError - app error interface

func IsAppError

func IsAppError(err error) (AppError, bool)

IsAppError checks if error is AppError

type EntityIDType

type EntityIDType interface {
	int32 | int64 | string
}

EntityIDType generics type for entity id

type Error

type Error[T EntityIDType] struct {
	Entity   string
	ID       T
	StatCode StatusCode
	Msg      string
}

Error - custom error wrapper

func NewForbiddenError

func NewForbiddenError[T EntityIDType](entity string, id T) Error[T]

NewForbiddenError - return new custom forbidden error

func NewInvalidError

func NewInvalidError[T EntityIDType](entity string, id T, msg string) Error[T]

NewInvalidError - return new custom invalid error

func NewNotFoundError

func NewNotFoundError[T EntityIDType](entity string, id T) Error[T]

NewNotFoundError - return new custom not found error

func NewTooManyRequestsError

func NewTooManyRequestsError(entity string, msg string) Error[int32]

NewTooManyRequestsError - return new custom too many requests error

func (Error[T]) Error

func (e Error[T]) Error() string

Error returns error description

func (Error[T]) HTTPStatusCode

func (e Error[T]) HTTPStatusCode() int

HTTPStatusCode returns status code

func (Error[T]) StatusCode

func (e Error[T]) StatusCode() StatusCode

StatusCode returns status code

type StatusCode

type StatusCode int

StatusCode - error status code

supported status codes

Jump to

Keyboard shortcuts

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