errors

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MPL-2.0-no-copyleft-exception Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is a generic error for things that don't exist.
	ErrNotFound = New("not found")

	// ErrInvalidAuth is for authentication events that do not succeed.
	ErrInvalidAuth = New("invalid authentication")

	// ErrRunCanceled is thrown to github when the run is canceled.
	ErrRunCanceled = New("run canceled by user intervention")
)

Functions

func Errorf

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

Errorf is the formatted version of New().

func MapError

func MapError(err error) error

MapError finds an error by string and returns an appropriate Error for it. The stack will NOT be preserved in the error and you will want to Wrap() it. If there is no potential mapping, a new Error is returned.

func New

func New(res interface{}) error

New constructs a new error

Types

type Error

type Error struct {
	Errs   []string        `json:"errors"`
	Frames []xerrors.Frame `json:"-"`
	Log    bool            `json:"log"`
}

Error encapsulates a series of errors.

func NewNoLog

func NewNoLog(str string) Error

NewNoLog returns an error which will not be logged.

func (Error) Contains

func (e Error) Contains(err interface{}) bool

Contains checks if e contains err. Strings and errors are supported; otherwise it will return false.

func (Error) Copy

func (e Error) Copy() Error

Copy makes a copy of the error: for great justice

func (Error) Error

func (e Error) Error() string

func (Error) Exit

func (e Error) Exit()

Exit exits the program leveraging the error for output before exiting with error code 1. If DEBUG is set, it will output a stack trace.

func (Error) Format

func (e Error) Format(f fmt.State, c rune)

Format formats the errors implementing fmt.Formatter

func (Error) FormatError

func (e Error) FormatError(p xerrors.Printer) error

FormatError implements xerrors.Formatter and allows it to provide extended detail.

func (*Error) GetLog

func (e *Error) GetLog() bool

GetLog returns the state of the log argument; for usage by error reporting utilities.

func (*Error) SetLog

func (e *Error) SetLog(log bool)

SetLog sets the state for whether or not logging is permitted.

func (Error) String

func (e Error) String() string

func (Error) ToGRPC

func (e Error) ToGRPC(code codes.Code) error

ToGRPC converts an error to a coded GRPC error, useful in returns from API handlers.

func (Error) Wrap

func (e Error) Wrap(err interface{}) Error

Wrap wraps an error string. If the original error is nil, no wrapping occurs and nil is returned.

func (Error) Wrapf

func (e Error) Wrapf(str string, args ...interface{}) Error

Wrapf wraps an error with formatting

Jump to

Keyboard shortcuts

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