errors

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

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 Errorf

func Errorf(s int, f string, a ...interface{}) *Error

func New

func New(s int, m string, c error) *Error

func Wrap

func Wrap(s int, m string, e error) *Error

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) AddDetail

func (e *Error) AddDetail(d map[string]interface{}) *Error

func (*Error) Copy

func (e *Error) Copy() *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Reference added in v2.4.0

func (e *Error) Reference() string

func (*Error) Response

func (e *Error) Response() *router.Response

func (*Error) SetCause

func (e *Error) SetCause(c error) *Error

func (*Error) SetCode

func (e *Error) SetCode(c Code) *Error

func (*Error) SetDetail

func (e *Error) SetDetail(d map[string]interface{}) *Error

func (*Error) SetFieldErrors

func (e *Error) SetFieldErrors(errs validate.Errors) *Error

func (*Error) SetHelp

func (e *Error) SetHelp(help string) *Error

func (*Error) SetStatus

func (e *Error) SetStatus(v int) *Error

func (*Error) String

func (e *Error) String() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Responder

type Responder interface {
	error
	Response() *router.Response
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL