Documentation ¶
Index ¶
- Variables
- func As(err error, target any) bool
- func CreateErrorFn(status int) func(msgs ...any) *Error
- func Is(err, target error) bool
- type Error
- func (e *Error) Error() string
- func (e *Error) Format(f fmt.State, c rune)
- func (e *Error) FormatError(p xerrors.Printer) error
- func (e *Error) MarshalJSON() ([]byte, error)
- func (e *Error) Messagef(format string, a ...any) *Error
- func (e *Error) Trace() error
- func (e *Error) Unwrap() error
- func (e *Error) Wrap(target error) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( InternalServerError = CreateErrorFn(http.StatusInternalServerError) Unauthenticated = CreateErrorFn(http.StatusUnauthorized) BadRequest = CreateErrorFn(http.StatusBadRequest) Forbidden = CreateErrorFn(http.StatusForbidden) NotFound = CreateErrorFn(http.StatusNotFound) BadGateway = CreateErrorFn(http.StatusBadGateway) UnprocessableEntity = CreateErrorFn(http.StatusUnprocessableEntity) )
Functions ¶
func CreateErrorFn ¶ added in v0.0.5
Types ¶
type Error ¶
type Error struct { Status int `json:"-"` Code string `json:"code,omitempty"` Message string `json:"message"` Detail string `json:"detail,omitempty"` // contains filtered or unexported fields }
Error is error object.
func GetErrorByStatus ¶
func New ¶
New creates new error object. Example: errors.New("Login failed", "LOGIN_FAILED", "Invalid username or password")
message: error message extras: error detail and error code
func (*Error) FormatError ¶
FormatError is error interface implementation.
func (*Error) MarshalJSON ¶
MarshalJSON is json.Marshaler interface implementation.
Click to show internal directories.
Click to hide internal directories.