Documentation ¶
Index ¶
- Variables
- func Cause(err error) error
- type DebugCarrier
- type DetailsCarrier
- type Err
- func (e Err) Debug() string
- func (e Err) Details() map[string]interface{}
- func (e Err) Error() string
- func (e Err) Is(err error) bool
- func (e Err) Reason() string
- func (e Err) RequestID() string
- func (e *Err) StackTrace() (trace errors.StackTrace)
- func (e Err) Status() string
- func (e Err) StatusCode() int
- func (e Err) Unwrap() error
- func (e Err) WithDebug(debug string) *Err
- func (e Err) WithDebugf(debug string, args ...interface{}) *Err
- func (e Err) WithDetail(key string, detail interface{}) *Err
- func (e Err) WithDetailf(key string, message string, args ...interface{}) *Err
- func (e Err) WithError(message string) *Err
- func (e Err) WithErrorf(message string, args ...interface{}) *Err
- func (e Err) WithReason(reason string) *Err
- func (e Err) WithReasonf(reason string, args ...interface{}) *Err
- func (e Err) WithRequestID(id string) *Err
- func (e *Err) WithTrace(err error) *Err
- func (e Err) WithWrap(err error) *Err
- func (e *Err) Wrap(err error)
- type ReasonCarrier
- type RequestIDCarrier
- type StackTracer
- type StatusCarrier
- type StatusCodeCarrier
Constants ¶
This section is empty.
Variables ¶
var ErrBadRequest = Err{ CodeField: http.StatusBadRequest, StatusField: http.StatusText(http.StatusBadRequest), ErrorField: " malformed request or invalid parameters", }
var ErrForbidden = Err{ CodeField: http.StatusForbidden, StatusField: http.StatusText(http.StatusForbidden), ErrorField: "forbidden requested action", }
var ErrInternalServerError = Err{ CodeField: http.StatusInternalServerError, StatusField: http.StatusText(http.StatusInternalServerError), ErrorField: "internal server error occurred", }
var ErrNotFound = Err{ CodeField: http.StatusNotFound, StatusField: http.StatusText(http.StatusNotFound), ErrorField: "resource not found", }
http.StatusUnauthorized, StatusField: http.StatusText(http.StatusUnauthorized), ErrorField: "authorized request", }CodeField:
var ErrUnsupportedMediaType = Err{ CodeField: http.StatusUnsupportedMediaType, StatusField: http.StatusText(http.StatusUnsupportedMediaType), ErrorField: "unsupported content type", }
Functions ¶
func Cause ¶
Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:
type causer interface { Cause() error }
If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.
Types ¶
type DebugCarrier ¶
type DebugCarrier interface { // Debug returns debugging information for the error, if applicable. Debug() string }
DebugCarrier can be implemented by an error to support error contexts.
type DetailsCarrier ¶
type DetailsCarrier interface { // Details returns details on the error, if applicable. Details() map[string]interface{} }
DetailsCarrier can be implemented by an error to support error contexts.
type Err ¶
type Err struct { CodeField int `json:"code,omitempty"` StatusField string `json:"status,omitempty"` RIDField string `json:"request,omitempty"` ReasonField string `json:"reason,omitempty"` DebugField string `json:"debug,omitempty"` DetailsField map[string]interface{} `json:"details,omitempty"` ErrorField string `json:"message"` // contains filtered or unexported fields }
func (*Err) StackTrace ¶
func (e *Err) StackTrace() (trace errors.StackTrace)
StackTrace returns the error's stack trace.
func (Err) StatusCode ¶
func (Err) WithDebugf ¶
func (Err) WithDetail ¶
func (Err) WithDetailf ¶
func (Err) WithErrorf ¶
func (Err) WithReason ¶
func (Err) WithReasonf ¶
func (Err) WithRequestID ¶
type ReasonCarrier ¶
type ReasonCarrier interface { // Reason returns the reason for the error, if applicable. Reason() string }
ReasonCarrier can be implemented by an error to support error contexts.
type RequestIDCarrier ¶
type RequestIDCarrier interface { // RequestID returns the ID of the request that caused the error, if applicable. RequestID() string }
RequestIDCarrier can be implemented by an error to support error contexts.
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}
StackTracer can be implemented by an error to support errors stack trace.
type StatusCarrier ¶
type StatusCarrier interface { // ID returns the error id, if applicable. Status() string }
StatusCarrier can be implemented by an error to support error contexts.
type StatusCodeCarrier ¶
type StatusCodeCarrier interface { // StatusCode returns the status code of this error. StatusCode() int }
StatusCodeCarrier can be implemented by an error to support setting status codes in the error itself.