errors

package module
v0.0.0-...-701c88d Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadMethod = NewCode(400, "bad request method")

ErrBadMethod is a simple "400 Bad Request Method" Error.

View Source
var ErrInternal = NewCode(500, "internal server error")

ErrInternal is a simple "500 Internal Server Error".

View Source
var ErrNotFound = NewCode(404, "not found")

ErrNotFound is a simple "404 Not Found" Error.

View Source
var ErrUnauthorized = NewCode(401, "unauthorized")

ErrUnauthorized is a simple "401 Unauthorized" Error.

Functions

func Code

func Code(err error) int

Code returns the status code of the CodeError, if any. It returns 0 otherwise.

func ErrorCode

func ErrorCode(err error) int

func ErrorName

func ErrorName(err error) (name string, description string)

func Join

func Join(errs ...error) error

func JoinNew

func JoinNew(err error, format string, a ...interface{}) error

func New

func New(format string, a ...interface{}) error

New returns an error that formats as the given text.

func NewCode

func NewCode(code int, format string, a ...interface{}) error

func Rich

func Rich(err error) error

func Safe

func Safe(err error) (error, error)

func Stack

func Stack(err error) []error

func Unwrap

func Unwrap(err error) error

func Wrap

func Wrap(err error, causedBy error) error

Types

type CodeError

type CodeError interface {
	error
	ErrorCode() int
}

type DataError

type DataError interface {
	error
	ErrorData() interface{}
}

type DescError

type DescError interface {
	error
	ErrorDescription() string
}

type LinkError

type LinkError interface {
	error
	ErrorLink() string
}

type Multi

type Multi []error

func (*Multi) Append

func (multi *Multi) Append(errs ...error)

func (Multi) Error

func (multi Multi) Error() string

func (Multi) Reduce

func (multi Multi) Reduce() error

type NameError

type NameError interface {
	error
	ErrorName() string
}

type RichError

type RichError struct {
	Name     string      `json:"name"`
	Code     int         `json:"code,omitempty"`
	Desc     string      `json:"desc,omitempty"`
	Link     string      `json:"link,omitempty"`
	Data     interface{} `json:"data,omitempty"`
	CausedBy error       `json:"causedBy,omitempty"`
}

func NewRich

func NewRich(name string, code int, desc string, link string, data interface{}, causedBy error) *RichError

func (RichError) Error

func (r RichError) Error() string

func (RichError) ErrorCode

func (r RichError) ErrorCode() int

func (RichError) ErrorData

func (err RichError) ErrorData() interface{}

func (RichError) ErrorDescription

func (r RichError) ErrorDescription() string
func (r RichError) ErrorLink() string

func (RichError) ErrorName

func (r RichError) ErrorName() string

func (RichError) Unwrap

func (r RichError) Unwrap() error

Jump to

Keyboard shortcuts

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