Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var BadRequest = APIError{ Message: "bad request", Status: http.StatusBadRequest, Code: "BAD_REQUEST", }
BadRequest an error indicating a bad request
View Source
var InternalServerError = APIError{ Message: "an internal server error occurred", Status: http.StatusInternalServerError, Code: "INTERNAL_SERVER_ERROR", }
InternalServerError a standard API error message
View Source
var NotFoundError = APIError{ Message: "no resource found", Status: http.StatusNotFound, Code: "NOT_FOUND", }
NotFoundError an error indicating the resource couldn't be locating using the provided parameters
Functions ¶
func NewErrorHandler ¶
func NewErrorHandler(logger logz.FieldLogger) fiber.ErrorHandler
NewErrorHandler returns a fiber compatible error handler
Types ¶
type APIError ¶
type APIError struct { Message string `json:"message"` Status int `json:"status"` Code string `json:"code"` Context map[string]interface{} `json:"context"` }
APIError the base element of an API error
func (APIError) WithContext ¶
WithContext creates a copy of the error with added context values
Click to show internal directories.
Click to hide internal directories.