detail

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(what interface{}, flags ...Flag) error

New creates a detail error with optional stacktrace, an inner error, alias and so on.

Types

type Detail

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

Detail error contains a message, stack traces and an inner error. Usually, it is used by other errors and should always be created by `Make` or `New`.

func Make

func Make(what interface{}, flags ...Flag) Detail

Make detail error. It is used to create other errors with stack trace and an inner error.

func (*Detail) Cause

func (e *Detail) Cause() error

Cause is an alias of Unwrap. May be needed in `pkg/errors`.

func (*Detail) Error

func (e *Detail) Error() string

Error implements the error interface.

func (*Detail) Format

func (e *Detail) Format(s fmt.State, v rune)

Format implements the Format method used for *Printf.

func (*Detail) FormatError

func (e *Detail) FormatError(p xerrors.Printer) (next error)

FormatError formats this error with stack trace and inner errors.

func (*Detail) Is

func (e *Detail) Is(err error) bool

Is compares this error with another. The alias will also be compared.

func (*Detail) Unwrap

func (e *Detail) Unwrap() error

Unwrap this error and get the inner error.

type Flag

type Flag func(*Detail)

Flag is used to add optional parameter to `detail.New(...)` By using those flags, we could custom error while `New` error. See: https://stackoverflow.com/a/26326418

func FlagAlias

func FlagAlias(err error) Flag

FlagAlias set an alias (error value) to this error. We could use `errors.Is(err, alias)` to test it.

func FlagInner

func FlagInner(err error) Flag

FlagInner adds an inner error to this error. All error messages will be joined with a ": " when outputting.

func FlagStackTrace

func FlagStackTrace(skip uint) Flag

FlagStackTrace add a stack trace to our error.

  • `skip` top n stack trace.

Jump to

Keyboard shortcuts

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