errors

package
v0.114.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As added in v0.102.0

func As(err error, target interface{}) bool

As is a wrapper around the errors.As function.

func Code

func Code(err error) codes.Code

Code returns the error code for the given error. If the error is not a flux.Error, this will return Unknown for the code. If the error is a flux.Error and its code is Inherit, then this will return the wrapped error's code.

func DocURL added in v0.82.0

func DocURL(err error) string

DocURL returns the DocURL associated with this error if one exists. This will return the outermost DocURL associated with this error unless the code is Inherit. If the code for an error is Inherit, this will return the DocURL for the nested error if it exists.

func Is added in v0.100.0

func Is(err, target error) bool

Is is a wrapper around the errors.Is function.

Types

type Error

type Error struct {
	// Code is the code of the error as defined in the codes package.
	// This describes the type and category of the error. It is required.
	Code codes.Code

	// Msg contains a human-readable description and additional information
	// about the error itself. This is optional.
	Msg string

	// DocURL contains a link to documentation that is related to explaining
	// details and/or solutions to this error message.
	DocURL string

	// Err contains the error that was the cause of this error.
	// This is optional.
	Err error
}

Error is the error struct of flux.

func New

func New(code codes.Code, msg ...interface{}) *Error

func Newf

func Newf(code codes.Code, fmtStr string, args ...interface{}) *Error

func WithDocURL added in v0.83.0

func WithDocURL(err error, docURL string) *Error

WithDocURL will annotate an error with a DocURL. If the error is an Error and the DocURL is not filled, it will be set. If the error is not an Error or the DocURL is filled, it will wrap the error and set the DocURL on the wrapper error.

func Wrap

func Wrap(err error, code codes.Code, msg ...interface{}) *Error

func Wrapf

func Wrapf(err error, code codes.Code, format string, a ...interface{}) *Error

func (*Error) Error

func (e *Error) Error() string

Error implement the error interface by outputting the Code and Err.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap will return the wrapped error.

func (*Error) WithDocURL added in v0.83.0

func (e *Error) WithDocURL(docURL string) *Error

WithDocURL can be used to add a documentation URL to the error.

Jump to

Keyboard shortcuts

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