Documentation
¶
Index ¶
- Constants
- func ApplyFormatter(formatter Formatter)
- func Cause(err error) error
- func Errorf(msg string, args ...interface{}) error
- func GrpcError(code codes.Code, msg string) error
- func GrpcErrorf(code codes.Code, msg string, args ...interface{}) error
- func New(msg string) error
- func StackTrace(err error) string
- func Wrap(err error) error
- func WrapMessage(err error, msg string) error
- func WrapMessagef(err error, msg string, args ...interface{}) error
- type Formatter
Constants ¶
const ( DefaultFormatter Formatter = "file.go:152\n" JavaLikeFormatter = "at foo(file.go:152)\n" GoLikeFormatter = "foo\n\tfile.go:152\n" PythonLikeFormatter = "File file.go, line 152, in foo\n" )
constants for Stack formatters.
Variables ¶
This section is empty.
Functions ¶
func ApplyFormatter ¶
func ApplyFormatter(formatter Formatter)
ApplyFormatter specifies the formatter for errorTracer. Apply DefaultFormatter if not specified. The template of formatter: "foo" for function name, "file.go" for file name, "152" for line number.
func Cause ¶
Cause returns the original error of a traceable error. If the error is not traceable, return itself.
func Errorf ¶
Errorf creates a traceable error with formatted message. If args contains a traceable error, apply the stack of it. If args doesn't contain any traceable error, record the stack trace.
func GrpcErrorf ¶
GrpcErrorf creates a traceable error with formatted message and gRPC status code. If args contains a traceable error, apply the stack of it. If args doesn't contain a traceable error, record the stack trace.
func StackTrace ¶
StackTrace prints the stack trace with given error by the formatter. If the error is not traceable, empty string is returned.
func Wrap ¶
Wrap wraps an error into a traceable error. If the wrapped error is traceable, do nothing. If the wrapped error is not traceable, record the stack trace.
func WrapMessage ¶
WrapMessage wraps an error into a traceable error with message. If the wrapped error is traceable, only append the error message. If the wrapped error is not traceable, record the stack trace.
func WrapMessagef ¶
WrapMessagef wraps an error into a traceable error with formatted message. If the wrapped error is traceable, only append the error message. If the wrapped error is not traceable, record the stack trace.