errors

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: BSD-3-Clause Imports: 4 Imported by: 1

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 is already a REST Error, it 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) 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) String

func (e Error) String() string

Jump to

Keyboard shortcuts

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