errorsx

package
Version: v0.0.0-...-421db18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadRequest = Err{
	CodeField:   http.StatusBadRequest,
	StatusField: http.StatusText(http.StatusBadRequest),
	ErrorField:  " malformed request or invalid parameters",
}
View Source
var ErrForbidden = Err{
	CodeField:   http.StatusForbidden,
	StatusField: http.StatusText(http.StatusForbidden),
	ErrorField:  "forbidden requested action",
}
View Source
var ErrInternalServerError = Err{
	CodeField:   http.StatusInternalServerError,
	StatusField: http.StatusText(http.StatusInternalServerError),
	ErrorField:  "internal server error occurred",
}
View Source
var ErrNotFound = Err{
	CodeField:   http.StatusNotFound,
	StatusField: http.StatusText(http.StatusNotFound),
	ErrorField:  "resource not found",
}
View Source
var ErrUnauthorized = Err{
	CodeField:   http.StatusUnauthorized,
	StatusField: http.StatusText(http.StatusUnauthorized),
	ErrorField:  "authorized request",
}
View Source
var ErrUnsupportedMediaType = Err{
	CodeField:   http.StatusUnsupportedMediaType,
	StatusField: http.StatusText(http.StatusUnsupportedMediaType),
	ErrorField:  "unsupported content type",
}

Functions

func Cause

func Cause(err error) error

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 ToErr

func ToErr(err error, id string) *Err

func (Err) Debug

func (e Err) Debug() string

func (Err) Details

func (e Err) Details() map[string]interface{}

func (Err) Error

func (e Err) Error() string

func (Err) Is

func (e Err) Is(err error) bool

func (Err) Reason

func (e Err) Reason() string

func (Err) RequestID

func (e Err) RequestID() string

func (*Err) StackTrace

func (e *Err) StackTrace() (trace errors.StackTrace)

StackTrace returns the error's stack trace.

func (Err) Status

func (e Err) Status() string

func (Err) StatusCode

func (e Err) StatusCode() int

func (Err) Unwrap

func (e Err) Unwrap() error

func (Err) WithDebug

func (e Err) WithDebug(debug string) *Err

func (Err) WithDebugf

func (e Err) WithDebugf(debug string, args ...interface{}) *Err

func (Err) WithDetail

func (e Err) WithDetail(key string, detail interface{}) *Err

func (Err) WithDetailf

func (e Err) WithDetailf(key string, message string, args ...interface{}) *Err

func (Err) WithError

func (e Err) WithError(message string) *Err

func (Err) WithErrorf

func (e Err) WithErrorf(message string, args ...interface{}) *Err

func (Err) WithReason

func (e Err) WithReason(reason string) *Err

func (Err) WithReasonf

func (e Err) WithReasonf(reason string, args ...interface{}) *Err

func (Err) WithRequestID

func (e Err) WithRequestID(id string) *Err

func (*Err) WithTrace

func (e *Err) WithTrace(err error) *Err

func (Err) WithWrap

func (e Err) WithWrap(err error) *Err

func (*Err) Wrap

func (e *Err) Wrap(err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL