errors

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

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"`
}

func Errorf

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

func New

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

func Wrap added in v1.2.0

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 added in v1.8.0

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

func (*Error) Copy added in v1.4.3

func (e *Error) Copy() *Error

func (*Error) Error

func (e *Error) Error() 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 added in v1.8.0

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

func (*Error) SetStatus added in v1.4.3

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

func (*Error) String

func (e *Error) String() string

func (*Error) Unwrap added in v1.3.5

func (e *Error) Unwrap() error

type Responder added in v1.7.0

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