er

package
v0.0.0-...-0cf96f8 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: ISC, ISC Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOF = GenericErrorType.CodeWithDefault("EOF", io.EOF)
View Source
var ErrUnexpectedEOF = GenericErrorType.CodeWithDefault("ErrUnexpectedEOF", io.ErrUnexpectedEOF)
View Source
var GenericErrorType = NewErrorType("er.GenericErrorType")

GenericErrorType is for packages with only one or two error codes which don't make sense having their own error type

View Source
var LoopBreak = E(errrLoopbreak)

A (non) error which is used to break out of a forEach loop

Functions

func Cis

func Cis(code *ErrorCode, e R) bool

func Equals

func Equals(e, r R) bool

func FuzzyEquals

func FuzzyEquals(e, r R) bool

func IsLoopBreak

func IsLoopBreak(e R) bool

func Native

func Native(err R) error

func Wrapped

func Wrapped(err R) error

Types

type ErrorCode

type ErrorCode struct {
	Detail string
	Number int
	Type   *ErrorType
	// contains filtered or unexported fields
}

ErrorCode is a code for identifying a particular type of fault. Error codes can have a numeric code identifier or they can not.

func (*ErrorCode) Default

func (c *ErrorCode) Default() R

func (*ErrorCode) Is

func (c *ErrorCode) Is(err R) bool

func (*ErrorCode) New

func (c *ErrorCode) New(info string, err R) R

type ErrorType

type ErrorType struct {
	Name string

	Codes []*ErrorCode
	// contains filtered or unexported fields
}

ErrorType is a generic type of error, each type can have many error codes

func NewErrorType

func NewErrorType(ident string) ErrorType

NewErrorType creates a new error type, it must be identified by name. For example: var MyError er.ErrorType = NewErrorType("mypackage.MyError")

func (*ErrorType) Code

func (e *ErrorType) Code(info string) *ErrorCode

func (*ErrorType) CodeWithDefault

func (e *ErrorType) CodeWithDefault(info string, defaultError error) *ErrorCode

func (*ErrorType) CodeWithDetail

func (e *ErrorType) CodeWithDetail(info string, detail string) *ErrorCode

func (*ErrorType) CodeWithNumber

func (e *ErrorType) CodeWithNumber(info string, number int) *ErrorCode

func (*ErrorType) CodeWithNumberAndDetail

func (e *ErrorType) CodeWithNumberAndDetail(info string, number int, detail string) *ErrorCode

func (*ErrorType) Decode

func (e *ErrorType) Decode(err R) *ErrorCode

func (*ErrorType) Is

func (e *ErrorType) Is(err R) bool

func (*ErrorType) NumberToCode

func (e *ErrorType) NumberToCode(number int) *ErrorCode

type R

type R interface {
	Message() string
	Stack() []string
	HasStack() bool
	String() string
	Wrapped0() error
	Native() error
	AddMessage(m string)
}

func E

func E(e error) R

func Errorf

func Errorf(format string, a ...interface{}) R

func New

func New(s string) R

Jump to

Keyboard shortcuts

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