Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrForbidden = errorx.CommonErrors.NewType("forbidden") ErrBadRequest = errorx.CommonErrors.NewType("bad_request") ErrNotFound = errorx.CommonErrors.NewType("not_found") )
Functions ¶
func ErrorHandlerFn ¶
func ErrorHandlerFn() gin.HandlerFunc
ErrorHandlerFn creates a handler func that turns (last) error in the context into an APIError json response. In handlers, `c.Error(err)` can be used to attach the error to the context. When error is attached in the context: - The handler can optionally assign the HTTP status code. - The handler must not self-generate a response body.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Error bool `json:"error"` Message string `json:"message"` Code string `json:"code"` FullText string `json:"full_text"` }
func NewErrorResponse ¶
func NewErrorResponse(err error) ErrorResponse
Click to show internal directories.
Click to hide internal directories.