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 ¶
IsAppError checks if error is AppError
type EntityIDType ¶
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 ¶
NewTooManyRequestsError - return new custom too many requests error
func (Error[T]) HTTPStatusCode ¶
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
const ( NotFound StatusCode = http.StatusNotFound Invalid StatusCode = http.StatusBadRequest Forbidden StatusCode = http.StatusForbidden TooManyRequests StatusCode = http.StatusTooManyRequests )
supported status codes
Click to show internal directories.
Click to hide internal directories.