errors

package
v0.28.20250127053704 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Catch

func Catch(e error, action Action) bool

func ErrorFormat added in v0.28.20240114140844

func ErrorFormat(e error, format ...ErrFormat) (s string)

func Join added in v0.28.20240114140844

func Join(e ...error) error

func Unwrap added in v0.28.20240114140844

func Unwrap(e error) []error

Types

type Action added in v0.28.20250120132246

type Action string

func (Action) Append added in v0.28.20250120153835

func (t Action) Append(child string) Action

func (Action) New added in v0.28.20250120183746

func (t Action) New(reason ...string) (e Error)

type ErrFormat added in v0.28.20240903115607

type ErrFormat func(e error) string
var (
	ErrSimplifyFunc ErrFormat = func(e error) string {
		return e.Error() + "\n"
	}
	ErrActionSimplifyFunc ErrFormat = func(e error) string {
		if err, ok := e.(Error); ok && string(err.action) != err.Reason {
			return string(err.action) + ":" + e.Error() + "\n"
		} else {
			return e.Error() + "\n"
		}
	}
	ErrInLineFunc ErrFormat = func(e error) string {
		return "> " + e.Error() + " "
	}
	ErrActionInLineFunc ErrFormat = func(e error) string {
		if err, ok := e.(Error); ok && string(err.action) != err.Reason {
			return "> " + string(err.action) + ":" + e.Error() + " "
		} else {
			return "> " + e.Error() + " "
		}
	}
)

type Error

type Error struct {
	Reason string
	// contains filtered or unexported fields
}

func New

func New(reason string, action ...Action) (e Error)

func (Error) Error

func (t Error) Error() string

func (Error) Is added in v0.28.20250120183746

func (t Error) Is(e error) bool

func (Error) Unwrap added in v0.28.20250120183746

func (t Error) Unwrap() error

func (Error) WithReason added in v0.28.20240325172911

func (t Error) WithReason(reason string) Error

Jump to

Keyboard shortcuts

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