errorutil

package
v0.0.0-...-31532db Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShowStackTrace bool = false

ShowStackTrace in Error Message

Functions

This section is empty.

Types

type ErrCallback

type ErrCallback func(level ErrorLevel, err string, tags ...string)

ErrCallback function to handle given error

type Error

type Error interface {
	// WithTag assigns tag[s] to Error
	WithTag(tag ...string) Error
	// WithLevel assigns given ErrorLevel
	WithLevel(level ErrorLevel) Error
	// Error is interface method of 'error'
	Error() string
	// Wraps existing error with errors (skips if passed error is nil)
	Wrap(err ...error) Error
	// Msgf wraps error with given message
	Msgf(format string, args ...any) Error
	// Equal Checks Equality of errors
	Equal(err ...error) bool
	// WithCallback execute ErrCallback function when Error is triggered
	WithCallback(handle ErrCallback) Error
}

Error is enriched version of normal error with tags, stacktrace and other methods

func New

func New(format string, args ...any) Error

New

func NewWithErr

func NewWithErr(err error) Error

func NewWithTag

func NewWithTag(tag string, format string, args ...any) Error

NewWithTag creates an error with tag

type ErrorLevel

type ErrorLevel uint
const (
	Panic ErrorLevel = iota
	Fatal
	Runtime // Default
)

func (ErrorLevel) String

func (l ErrorLevel) String() string

Jump to

Keyboard shortcuts

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