errors

package
v0.0.0-...-def9258 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Unknown specifies an unknown error.
	Unknown = ErrorType(iota)
	// BadRequest specifies a validation realted error.
	BadRequest
	// Unauthorized specifies authentication related errors.
	Unauthorized
	// Forbidden specifies authorization (permission) related errors.
	Forbidden
	// NotFound specifies errors related with non-existent resources.
	NotFound
	// Conflict specifies errors related with a resource conflict.
	Conflict
	// Unexpected specifies errors occurring unexpectedly, caused by technical issues.
	Unexpected
)

Variables

This section is empty.

Functions

func AddContext

func AddContext(err error, field, message string) error

AddContext adds context to the given error.

func Cause

func Cause(err error) error

Cause returns the cause of the given error.

func GetContext

func GetContext(err error) *map[string]string

GetContext returns an error's context.

func New

func New(message string) error

New constructs a new error with the given message.

func Newf

func Newf(message string, args ...interface{}) error

Newf constructs a new error with the given message format and args.

func Wrap

func Wrap(err error, message string) error

Wrap wraps the given error with a new message.

func Wrapf

func Wrapf(err error, message string, args ...interface{}) error

Wrapf wraps the given error with a new message format and arguments.

Types

type ErrorType

type ErrorType string

ErrorType defines an enum for all possible kinds of errors.

func GetType

func GetType(err error) ErrorType

GetType returns the type of the given error.

func (ErrorType) New

func (typ ErrorType) New(message string) error

New creates a new error for the given message.

func (ErrorType) Newf

func (typ ErrorType) Newf(message string, args ...interface{}) error

Newf creates a new error with the given message format and arguments.

func (ErrorType) Wrap

func (typ ErrorType) Wrap(err error, message string) error

Wrap wraps a given error with a new message.

func (ErrorType) Wrapf

func (typ ErrorType) Wrapf(err error, message string, args ...interface{}) error

Wrapf wraps a given error with a new message format and arguments.

Jump to

Keyboard shortcuts

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