errs

package
v0.0.0-...-8685a14 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultErrsKindKey = 0
View Source
const DefaultErrsSeverityKey ctxErrsSeverityKey = 0

Variables

Functions

func SetDefaultErrsKind

func SetDefaultErrsKind(kind Kind) cu.PartialContextFn

func SetDefaultErrsSeverity

func SetDefaultErrsSeverity(severity Severity) cu.PartialContextFn

func WithFrames

func WithFrames(b bool)

Types

type Error

type Error interface {
	error
	Severity() Severity
	TimeStamp() time.Time
	Kind() Kind
	OperationPath() cou.Operations
	StackTrace() []Frame
	Unwrap() error
}

func E

func E(args ...interface{}) Error

type Frame

type Frame struct {
	// Func contains a function name.
	Func string
	// Line contains a line number.
	Line int
	// Path contains a file path.
	Path string
}

Frame is a single step in stack trace.

func (Frame) String

func (f Frame) String() string

String formats Frame to string.

type Frames

type Frames []Frame

func Trace

func Trace(skip int) (result Frames)

... or debug.Stack()

func (Frames) String

func (fs Frames) String() string

type Kind

type Kind uint32
const (
	KindOther           Kind = iota // Unclassified error. This value is not printed in the error message.
	KindTransient                   // Transient error  todo: use prev Error values
	KindInterrupted                 // Interrupted ( some kind of inconsistency )
	KindInvalidValue                // Invalid value for this type of item.
	KindIO                          // External I/O error such as network failure.
	KindOSOpenFile                  // os.Open errors
	KindOSStat                      // error returned from os.Lstat, os.Stat
	KindFileStat                    // FileStat creation failed
	KindPermission                  // Permission denied.
	KindExist                       // Item already exists.
	KindNotExist                    // Item does not exist.
	KindIsDir                       // Item is a directory.
	KindNotDir                      // Item is not a directory.
	KindFileSystemOther             // Other file system related error.
	KindBrokenLink                  // Link target does not exist.
	KindInternal                    // Internal error (for current errs pipeline impl this kind should be last in this list so that len(Kinds) = int(errs.KindInternal))
)

todo: make kind values as flags so that masks can be used to classify compound errors const KindOther Kind = 1 << (32 - 1 - iota)

func GetDefaultErrsKind

func GetDefaultErrsKind(ctx context.Context) Kind

func (Kind) String

func (k Kind) String() string

type Severity

type Severity uint32
const (
	SeverityWarning Severity = iota
	SeverityError
	SeverityCritical
)

func GetDefaultErrsSeverity

func GetDefaultErrsSeverity(ctx context.Context) Severity

func (Severity) String

func (s Severity) String() string

Jump to

Keyboard shortcuts

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