Documentation
¶
Index ¶
- Variables
- func Format(format string, args ...any) error
- func New(message string) error
- func Unwrap(err error) error
- func With(err error, message string) error
- func Wrap(err error, message string) error
- func Wrapf(err error, format string, args ...any) error
- type Frame
- type StackTrace
- type TracedError
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("value is invalid")
ErrInvalid indicates that a value or operation is invalid.
Functions and methods should not return this error but should instead return a wrap of this one.
var ErrUnexpected = errors.New("unexpected error")
ErrUnexpected indicates that the error is unexpected but happened. It's useful for debugging.
Functions and methods should not return this error but should instead return a wrap of this one.
Functions ¶
func Unwrap ¶ added in v0.26.1
Unwrap try to unwrap the err in *TracedError.
func With ¶
With wrap err as TracedError with message.
With doesn't reuse underlying TracedError if exists.
func Wrap ¶
Wrap construct stack TracedError by err and message.
Wrap try to use existing stack. If the err is already a [TracedError], it appends the message to the existing one.
Types ¶
type Frame ¶
type Frame uintptr
Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.
func (Frame) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%s source file %d source line %n function name %v equivalent to %s:%d
Format accepts flags that alter the printing of some verbs, as follows:
%+s function name and path of source file relative to the compile time
GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v equivalent to %+s:%d
func (Frame) MarshalText ¶
MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.
type StackTrace ¶
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
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 lists source files for each Frame in the stack %v lists the source file and line number for each Frame in the stack
Format accepts flags that alter the printing of some verbs, as follows:
%+v Prints filename, function, and line number for each Frame in the stack.
type TracedError ¶
type TracedError struct {
// contains filtered or unexported fields
}
func (*TracedError) Error ¶
func (w *TracedError) Error() string
func (*TracedError) Message ¶
func (w *TracedError) Message() string
func (*TracedError) SetUnderlying ¶
func (w *TracedError) SetUnderlying(err error)
SetUnderlying replace the underlying to new one.
func (*TracedError) Stack ¶
func (w *TracedError) Stack() StackTrace
func (TracedError) StackTrace ¶
func (s TracedError) StackTrace() StackTrace
func (*TracedError) Unwrap ¶
func (w *TracedError) Unwrap() error
Unwrap provides compatibility for Go 1.13 error chains.