Documentation ¶
Overview ¶
Package errors centralizes http error creation
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Is = errors.Is
Is is a drop in replacement for the standard errors package
var New = errors.New
New is a drop in replacement for the standard errors package
Functions ¶
Types ¶
type Code ¶
type Code string
Code is to make it easier to return a 400
func (Code) GetResponse ¶
func (e Code) GetResponse() interface{}
GetResponse returns the same object
type HTTPError ¶
type HTTPError interface { GetStatusCode() int GetResponse() interface{} }
HTTPError is an interface for structured errors
func DefaultTranslator ¶
DefaultTranslator handles types from echo and validator
type NoResponse ¶
type NoResponse int
NoResponse is a response with no body
func (NoResponse) GetResponse ¶
func (e NoResponse) GetResponse() interface{}
GetResponse returns the same object
func (NoResponse) GetStatusCode ¶
func (e NoResponse) GetStatusCode() int
GetStatusCode returns the status code
type Response ¶
type Response struct { StatusCode int `json:"-"` Code string `json:"code,omitempty"` Detail string `json:"detail,omitempty"` }
Response is the default structure of an error response
func (Response) GetResponse ¶
func (e Response) GetResponse() interface{}
GetResponse returns the same object
func (Response) GetStatusCode ¶
GetStatusCode returns the status code
type Translator ¶
Translator translates a function into an HTTPError or nil
type ValidationErrors ¶
type ValidationErrors validator.ValidationErrors
ValidationErrors is a wrapper around validator.ValidationErrors
func (ValidationErrors) Error ¶
func (ve ValidationErrors) Error() string
Error returns the validator.ValidationErrors's error
func (ValidationErrors) GetResponse ¶
func (ve ValidationErrors) GetResponse() interface{}
GetResponse returns the error detail
func (ValidationErrors) GetStatusCode ¶
func (ve ValidationErrors) GetStatusCode() int
GetStatusCode returns a bad request