errors

package
v2.5.0-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUnauthorized   = "ERR_UNAUTHORIZED"
	CodeBadRequest     = "ERR_BAD_REQUEST"
	CodeForbidden      = "ERR_FORBIDDEN"
	CodeNotFound       = "ERR_NOT_FOUND"
	CodeNotImplemented = "ERR_NOT_IMPLEMENTED"
	CodeTimeout        = "ERR_TIMEOUT"
	CodeInternal       = "ERR_INTERNAL"
)

Externally visible error codes

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:

type causer interface {
       Cause() error
}

If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.

func Errorf

func Errorf(code string, format string, args ...interface{}) error

Errorf returns an error and formats according to a format specifier

func InternalError

func InternalError(message string) error

InternalError is a convenience function to create a Internal error with a message

func InternalErrorf

func InternalErrorf(format string, args ...interface{}) error

InternalErrorf is a convenience function to format an Internal error

func InternalWrapError

func InternalWrapError(err error, message ...string) error

InternalWrapError annotates the error with the ERR_INTERNAL code and a stack trace, optional message

func InternalWrapErrorf

func InternalWrapErrorf(err error, format string, args ...interface{}) error

InternalWrapErrorf annotates the error with the ERR_INTERNAL code and a stack trace, optional message

func IsCode

func IsCode(code string, err error) bool

IsCode is a helper to determine if the error is of a specific code

func New

func New(code string, message string) error

New returns an error with the supplied message. New also records the stack trace at the point it was called.

func Wrap

func Wrap(err error, code string, message string) error

Wrap returns an error annotating err with a stack trace at the point Wrap is called, and a new supplied message. The previous original is preserved and accessible via Cause(). If err is nil, Wrap returns nil.

Types

type ArgoError

type ArgoError interface {
	Error() string
	Code() string
	Message() string
	JSON() []byte
	StackTrace() errors.StackTrace
	Format(s fmt.State, verb rune)
}

ArgoError is an error interface that additionally adds support for stack trace, error code, and a JSON representation of the error

Jump to

Keyboard shortcuts

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