Documentation
¶
Index ¶
- func Cause(err error) error
- func Code(err error) int
- func Details(err error) []string
- func Message(err error) string
- func Status(err error) int
- type Error
- func (x *Error) Cause() error
- func (x *Error) Code() int
- func (x *Error) Context() Map
- func (x *Error) Details() []string
- func (x *Error) Error() string
- func (x *Error) Format(state fmt.State, verb rune)
- func (x *Error) GRPCStatus() *status.Status
- func (x *Error) MarshalJSON() ([]byte, error)
- func (x *Error) MarshalXML(encoder *xml.Encoder, start xml.StartElement) error
- func (x *Error) Message() string
- func (x *Error) StackTrace() StackTrace
- func (x *Error) Status() int
- func (x *Error) Unwrap() error
- func (x Error) WithCode(code int) *Error
- func (x Error) WithContext(context Map) *Error
- func (x Error) WithDetails(text string, details ...string) *Error
- func (x Error) WithError(err error) *Error
- func (x Error) WithMessage(text string) *Error
- func (x Error) WithStatus(status int) *Error
- func (x *Error) Wrap(err error)
- type ErrorCollector
- func (errs ErrorCollector) As(err interface{}) bool
- func (errs ErrorCollector) Error() string
- func (errs ErrorCollector) Format(state fmt.State, verb rune)
- func (errs ErrorCollector) Is(target error) bool
- func (errs ErrorCollector) MarshalJSON() ([]byte, error)
- func (errs ErrorCollector) Unwrap() error
- func (errs *ErrorCollector) Wrap(err error)
- type ErrorConstant
- type Map
- type StackFrame
- type StackTrace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a wrapped error
func (*Error) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%m error message %d error details %c error code %r error reason %v code: %d message: %s details: %d reason: %w
Format accepts flags that alter the printing of some verbs, as follows:
%+s stack trace %+v equivalent
func (*Error) GRPCStatus ¶
GRPCStatus returns the grpc status of this error
func (*Error) MarshalJSON ¶
MarshalJSON marshals the error as json
func (*Error) MarshalXML ¶
MarshalXML marshals the error as xml
func (*Error) StackTrace ¶
func (x *Error) StackTrace() StackTrace
StackTrace returns the stack trace where the error occurred
func (Error) WithContext ¶
WithContext creates an error copy with given map
func (Error) WithDetails ¶
WithDetails creates an error copy with given details
func (Error) WithMessage ¶
WithMessage creates an error copy with given message
func (Error) WithStatus ¶
WithStatus creates an error copy with given status
type ErrorCollector ¶
type ErrorCollector []error
ErrorCollector is a slice of errors
func (ErrorCollector) As ¶
func (errs ErrorCollector) As(err interface{}) bool
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error matches target if the error's concrete value is assignable to the value pointed to by target, or if the error has a method As(interface{}) bool such that As(target) returns true. In the latter case, the As method is responsible for setting target.
As will panic if target is not a non-nil pointer to either a type that implements error, or to any interface type. As returns false if err is nil.
func (ErrorCollector) Error ¶
func (errs ErrorCollector) Error() string
Error returns the error message
func (ErrorCollector) Format ¶
func (errs ErrorCollector) Format(state fmt.State, verb rune)
Format the error as string
func (ErrorCollector) Is ¶
func (errs ErrorCollector) Is(target error) bool
Is reports whether any error in err's chain matches target.
The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling Unwrap.
An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.
func (ErrorCollector) MarshalJSON ¶
func (errs ErrorCollector) MarshalJSON() ([]byte, error)
MarshalJSON marshals the error as json
func (ErrorCollector) Unwrap ¶
func (errs ErrorCollector) Unwrap() error
Unwrap unwraps the underlying error it's only one
func (*ErrorCollector) Wrap ¶
func (errs *ErrorCollector) Wrap(err error)
Wrap appends an error to the slice
type ErrorConstant ¶
type ErrorConstant string
ErrorConstant represents an error that can create a constant / sentinel error such as io.EOF
type StackFrame ¶
StackFrame represents a program counter inside a stack frame. For historical reasons if StackFrame is interpreted as a uintptr its value represents the program counter + 1.
func (StackFrame) Format ¶
func (frame StackFrame) Format(state fmt.State, verb rune)
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 source file full path %+v equivalent to %+s:%d (%n)
func (StackFrame) MarshalText ¶
func (frame StackFrame) MarshalText() ([]byte, error)
MarshalText formats a stacktrace StackFrame 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 []StackFrame
StackTrace is stack of StackFrames from innermost (newest) to outermost (oldest).
func NewStackTraceAt ¶
func NewStackTraceAt(n int) StackTrace
NewStackTraceAt creates a new stack trace at given position
func (StackTrace) Format ¶
func (stack StackTrace) Format(state fmt.State, verb rune)
Format formats the stack of StackFrames according to the fmt.Formatter interface.
%s lists source files for each StackFrame in the stack %v lists the source file and line number for each StackFrame in the stack
Format accepts flags that alter the printing of some verbs, as follows:
%+v Prints filename, function, and line number for each StackFrame in the stack.