Documentation ¶
Index ¶
- type Code
- type Error
- func (e *Error) AddDetail(d map[string]interface{}) *Error
- func (e *Error) Copy() *Error
- func (e *Error) Error() string
- func (e *Error) Reference() string
- func (e *Error) Response() *router.Response
- func (e *Error) SetCause(c error) *Error
- func (e *Error) SetCode(c Code) *Error
- func (e *Error) SetDetail(d map[string]interface{}) *Error
- func (e *Error) SetFieldErrors(errs validate.Errors) *Error
- func (e *Error) SetHelp(help string) *Error
- func (e *Error) SetStatus(v int) *Error
- func (e *Error) String() string
- func (e *Error) Unwrap() error
- type Responder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { Status int `json:"-"` Code Code `json:"code,omitempty"` Message string `json:"message,omitempty"` Cause error `json:"-"` Detail map[string]interface{} `json:"detail,omitempty"` Ref string `json:"ref,omitempty"` }
func Wrap ¶
Conditionally wrap the parameter error in a REST Error. If the parameter error can be unwrapped as a REST Error, that error is simply returned. Otherwise, a new REST Error is created with the provided status, message and the parameter as the cause.
This is intended to be used in cases where the caller receives an error that may or may not be a REST Error and needs to report the result to the REST client. If the error is already a REST Error, that error should be reported, and if not, the underlying error should be wrapped in a more generic error.
func (*Error) SetFieldErrors ¶
Click to show internal directories.
Click to hide internal directories.