Documentation
¶
Overview ¶
Package errors provides error handling primitives.
Index ¶
- func As(err error, target any) bool
- func Errorf(format string, args ...any) error
- func Into[T error](err error) (target T, ok bool)
- func Is(err, target error) bool
- func Join(errs ...error) error
- func Kind(err error) error
- func New(msg string) error
- func Pack(kind error, args ...any) error
- func SetTrace(n int64)
- func Trace() bool
- func Unwrap(err error) error
- func Wrap(err error, msg string) error
- func Wrapf(err error, format string, args ...any) error
- type Error
- func (e *Error) As(target any) bool
- func (e *Error) Cause() error
- func (e *Error) Error() string
- func (e *Error) Format(s fmt.State, verb rune)
- func (e *Error) Is(target error) bool
- func (e *Error) Kind() error
- func (e *Error) Message() string
- func (e *Error) StackTrace() StackTrace
- func (e *Error) Unwrap() error
- type Frame
- type StackTrace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pack ¶
Pack creates a new error with a given kind. List of valid function signatures:
Pack(kind error) Pack(kind error, cause error) Pack(kind error, cause error, s string) Pack(kind error, cause error, format string, args ...any) Pack(kind error, s string) Pack(kind error, format string, args ...any)
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func (*Error) Format ¶
Format formats the stack of Frames according to the fmt.Formatter interface.
%s prints Error as is %v equivalent to %s %q prints Error in quotes
Accepts flags that alter the printing of some verbs, as follows:
%+s prints Error and it's stack trace (if it has one) %+v equivalent to %+s
func (*Error) StackTrace ¶
func (e *Error) StackTrace() StackTrace
type Frame ¶
func (*Frame) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%f source file %d source line %x function name %s equivalent to %x\n\t%f:%d %v equivalent to %s
func (Frame) MarshalText ¶
MarshalText formats a stacktrace frame as a text string. The output is the same as that of fmt.Sprintf("%x %f:%d", f).
type StackTrace ¶
type StackTrace []uintptr
func (StackTrace) Format ¶
func (st StackTrace) Format(s fmt.State, verb rune)
Format formats the stack of Frames according to the fmt.Formatter interface.
%s prints filename, function, and line number for each Frame in the stack. %v equivalent to %s
func (StackTrace) Iter ¶
func (st StackTrace) Iter() iter.Seq2[int, Frame]
Iter returns go1.23 iterator that wraps runtime.CallersFrames.
Click to show internal directories.
Click to hide internal directories.