errors

package module
v0.0.0-...-99ab850 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: GPL-3.0 Imports: 5 Imported by: 3

README

pipeline status coverage report

Coverage Report

Errors

A library that facilitates the creation of error. Not every error is a simple error string but could be composed of multiple values. An error data type that only contains the data pertaining to an error is more memory efficient than an error with a full error message. This is specially true for specific error messages rather tha generalized errors, which the standard Go error library already addresses very well.

Why?

The standard library is generic and does not provide specialized error handling. This library aims to ease the use of customized error messages.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(msg string) error

New creates a new error with a string message.

func NewF

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

NewF creates an error with a formating similar to sprintf.

func NewWithCaller

func NewWithCaller(msg string) error

NewWithCaller creates a new error that contains stack information.

func NewWithCallerF

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

NewWithCallerF creates a new error with a formatted message that contains stack information.

func PrintStackTrace

func PrintStackTrace()

PrintStackTrace prints the current stacktrace

func Wrap

func Wrap(err error, msg string) error

Wrap accepts an error and a message and wraps them together in a single error.

func WrapCaller

func WrapCaller(err error, msg string) error

WrapCaller wraps an error with stack information. The intent is to use the error information in an error message for easier debugging.

func WrapCallerF

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

WrapCallerF wraps an error with stack information with a formatted message. The intent is to use the additional error information for easier debugging.

func WrapF

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

WrapF accepts an error, wraps the error with a new message constructed from a format string and a list of arguments.

Types

type Caller

type Caller struct {
	// contains filtered or unexported fields
}

Caller represents the calling function within a given program state,

func GetCaller

func GetCaller() *Caller

GetCaller returns the current caller of the method in which GetCaller is called

func (*Caller) String

func (caller *Caller) String() string

String returns the file, the line number and the name of caller.

type EnhancedError

type EnhancedError interface {
	error
	CausedBy() error
	Stack() *StackTrace
}

EnhancedError describes an error that contains a stacktrace and any causes of the error.

type ErrorList

type ErrorList interface {
	ErrorListReader
	ErrorListWriter

	WithLock(f func(errorList ErrorListReadWrite) error) error
	WithRLock(f func(errorList ErrorListReader) error) error
}

func NewErrorList

func NewErrorList() ErrorList

NewErrorList creates a new error list that contains other errors.

type ErrorListReadWrite

type ErrorListReadWrite interface {
	ErrorListReader
	ErrorListWriter
}

type ErrorListReader

type ErrorListReader interface {
	Empty() bool
	Copy() ErrorList
	Error() string
	Slice() []error
}

type ErrorListWriter

type ErrorListWriter interface {
	AddError(err error)
	// contains filtered or unexported methods
}

type InvalidArgumentError

type InvalidArgumentError struct {
	// contains filtered or unexported fields
}

InvalidArgumentError is an error that is raised when a value is passed to a function that invalid.

func NewInvalidArgumentError

func NewInvalidArgumentError(argName string) *InvalidArgumentError

NewInvalidArgumentError creates a new InvalidArgumentError, which is an error to signify that a function received an argument that it did not expect

func (*InvalidArgumentError) Error

func (invalidArgumentError *InvalidArgumentError) Error() string

type PreConditionError

type PreConditionError struct {
	// contains filtered or unexported fields
}

PreConditionError is an error that occurs when there is a precondition that failed and thereby prevent a method or function from executing.

func NewPreconditionError

func NewPreconditionError(msg string) *PreConditionError

NewPreconditionError creates a new precondition error. Precondition errors indicate that there was a precondiiton for a function that failed.

func (*PreConditionError) Error

func (preCondition *PreConditionError) Error() string

type StackTrace

type StackTrace []uintptr

StackTrace is a wrapper around the call to runtime.Callers.

func NewStackTrace

func NewStackTrace(limit int) *StackTrace

NewStackTrace captures the state of the current stack.

func (*StackTrace) String

func (stackTrace *StackTrace) String() string

String returns a string representation of the stack.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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