Documentation
¶
Index ¶
- func ZapError(err error) zapcore.Field
- type Builder
- type Error
- func (x *Error) Category() string
- func (x *Error) Code() string
- func (x *Error) Detail() string
- func (x *Error) Error() string
- func (x *Error) Errorf(format string, args ...any) *Error
- func (x *Error) Format(s fmt.State, verb rune)
- func (x *Error) ID(id string) *Error
- func (x *Error) Is(target error) bool
- func (x *Error) LogValue() slog.Value
- func (x *Error) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (x *Error) Message() string
- func (x *Error) New() *Error
- func (x *Error) Printable() *printable
- func (x *Error) StackTrace() StackTrace
- func (x *Error) Stacks() []*Stack
- func (x *Error) Unstack() *Error
- func (x *Error) UnstackN(n int) *Error
- func (x *Error) Unwrap() error
- func (x *Error) Values() map[string]any
- func (x *Error) WithCategory(category string) *Error
- func (x *Error) WithCode(code string) *Error
- func (x *Error) WithDetail(detail string) *Error
- func (x *Error) WithValue(key string, value any) *Error
- func (x *Error) Wrap(cause error) *Error
- type Stack
- type StackTrace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder keeps a set of key-value pairs and can create a new error and wrap error with the key-value pairs.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is error interface for deepalert to handle related variables
func Unwrap ¶
Unwrap returns unwrapped goerr.Error from err by errors.As. If no goerr.Error, returns nil NOTE: Do not receive error interface. It causes typed-nil problem.
var err error = goerr.New("error") if err != nil { // always true
func Wrapf ¶
Wrapf creates a new Error and add message. The error message is formatted by fmt.Sprintf.
func (*Error) Errorf ¶ added in v0.8.0
Errorf creates a new Error and copy message and id to new one. The error message is formatted by fmt.Sprintf.
func (*Error) Format ¶
Format returns: - %v, %s, %q: formatted message - %+v: formatted message with stack trace
func (*Error) Is ¶
Is returns true if target is goerr.Error and Error.id of two errors are matched. It's for errors.Is. If Error.id is empty, it always returns false.
func (*Error) MarshalLogObject ¶
func (x *Error) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Error) StackTrace ¶
func (x *Error) StackTrace() StackTrace
StackTrace returns stack trace that is compatible with pkg/errors
func (*Error) Unstack ¶
Unstack trims stack trace by 1. It can be used for internal helper or utility functions.
func (*Error) UnstackN ¶
UnstackN trims stack trace by n. It can be used for internal helper or utility functions.
func (*Error) Values ¶
Values returns map of key and value that is set by With. All wrapped goerr.Error key and values will be merged. Key and values of wrapped error is overwritten by upper goerr.Error.
func (*Error) WithCategory ¶ added in v0.4.0
func (*Error) WithDetail ¶ added in v0.4.0
type StackTrace ¶
type StackTrace []frame
StackTrace is array of frame. It's exported for compatibility with github.com/pkg/errors
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.