structurederrors

package module
v0.0.0-...-6b997eb Latest Latest
Warning

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

Go to latest
Published: May 6, 2018 License: Apache-2.0 Imports: 7 Imported by: 15

README

structurederrors

Errors with context and other structured information

Errors in Golang lose context when one error leads to the calling function throwing an error, and its calling function throwing another error and so on.

Throwing errors using the functions provided in this library allow the user to capture the cascade of errors that are thrown.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitWithErr

func ExitWithErr(msg interface{})

func InvalidInstanceError

func InvalidInstanceError(obj interface{}) error

InvalidInstanceError means that obj is the correct type, but there's something wrong with its contents.

func InvalidInstanceErrorf

func InvalidInstanceErrorf(obj interface{}, msgFormat string, args ...interface{}) error

InvalidInstanceErrorf is like InvalidInstanceError, except with a custom message.

func InvalidValueErrorf

func InvalidValueErrorf(val interface{}, msgFormat string, args ...interface{}) error

InvalidValueErrorf is used when the type isn't meaningful--just the contents and the context matter.

func InvalidValueForTypeError

func InvalidValueForTypeError(val, typedObj interface{}) error

InvalidValueForTypeError is used when the type isn't meaningful--just the contents and the context matter.

func InvalidValueForTypeErrorf

func InvalidValueForTypeErrorf(val, typedObj interface{}, msgFormat string, args ...interface{}) error

InvalidValueForTypeErrorf is used when the type isn't meaningful--just the contents and the context matter.

func PrettyError

func PrettyError(err error) string

func ReversedStringsList

func ReversedStringsList(stringsList []string) []string

func SetVerboseErrors

func SetVerboseErrors(verbose bool)

func TypeError

func TypeError(obj interface{}) error

TypeError means that obj has an unexpected type.

func TypeErrorf

func TypeErrorf(obj interface{}, msgFormat string, args ...interface{}) error

TypeErrorf is like TypeError, except with a custom message.

func UsageErrorf

func UsageErrorf(commandPath, f interface{}, args ...interface{}) error

Types

type ErrorWithContext

type ErrorWithContext struct {
	BaseError error
	Context   []string
}

func ContextualizeErrorf

func ContextualizeErrorf(err error, contextFormat string, contextArgs ...interface{}) *ErrorWithContext

ContextualizeErrorf is for adding an additional message to an existing error. This method is only intended for simple messages (contextFormat). e.g. If the context includes a printout of a Go struct, use one of the other error generators in this package.

func InvalidInstanceContextErrorf

func InvalidInstanceContextErrorf(baseError error, obj interface{}, msgFormat string, args ...interface{}) *ErrorWithContext

InvalidInstanceContextErrorf is like InvalidInstanceContextErrorf, except it adds its message as context to an existing error.

func InvalidValueContextErrorf

func InvalidValueContextErrorf(baseError error, val interface{}, msgFormat string, args ...interface{}) *ErrorWithContext

func InvalidValueForTypeContextError

func InvalidValueForTypeContextError(baseError error, val, typedObj interface{}) *ErrorWithContext

func InvalidValueForTypeContextErrorf

func InvalidValueForTypeContextErrorf(baseError error, val, typedObj interface{}, msgFormat string, args ...interface{}) *ErrorWithContext

func TypeContextErrorf

func TypeContextErrorf(baseError error, obj interface{}, msgFormat string, args ...interface{}) *ErrorWithContext

TypeContextErrorf is like TypeErrorf, but it adds its message as context to an existing error.

func (*ErrorWithContext) Error

func (e *ErrorWithContext) Error() string

func (*ErrorWithContext) PrettyError

func (e *ErrorWithContext) PrettyError() string

Jump to

Keyboard shortcuts

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