Documentation
¶
Index ¶
- func Auto()
- func AutoHTTP(next http.Handler) http.Handler
- func EnableAuto()
- func JoinErrors(errs ...error) error
- func Print(err error)
- func Recover(fn func())
- func SetSkipPackages(pkgs ...string)
- func StackTrace(err error) []uintptr
- func Trace(msg string) error
- func WError(err error) error
- func WithCode(code string, err error) error
- func Wrap(err error) error
- type MultiError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoHTTP ¶
AutoHTTP returns an HTTP middleware that recovers from panics and renders a rich stack trace (in dev mode, as plain text; in any case the full trace is logged to stderr).
func EnableAuto ¶
func EnableAuto()
EnableAuto enables automatic panic recovery (stub for future use).
func JoinErrors ¶
JoinErrors merges multiple errors into a single MultiError. Returns nil if none.
func Print ¶
func Print(err error)
Print renders a rich trace (file:line + source context) for a wrapped error, following the same format as Auto().
func Recover ¶
func Recover(fn func())
Recover catches a panic in fn, prints a clean stack trace to stderr with file:line and function names, then exits with status 1. The panic always terminates the process.
func SetSkipPackages ¶
func SetSkipPackages(pkgs ...string)
SetSkipPackages appends packages to the skip list for stack trace filtering.
func StackTrace ¶
StackTrace unwraps err and returns the captured stack frames, if any.
func Trace ¶
Trace captures a stack trace at this point without modifying or wrapping an existing error. Useful in defers to annotate "where did this come from".
func WError ¶
WError is an opinionated Wrap that includes the stack trace directly in Error(). Use it when you always want the trace visible on every print.
Types ¶
type MultiError ¶
type MultiError struct {
Errors []error
}
MultiError aggregates multiple errors into one.
func (*MultiError) Append ¶
func (e *MultiError) Append(errs ...error)
Append adds non-nil errors to the collection.
func (*MultiError) Error ¶
func (e *MultiError) Error() string
Error returns a concatenated error message.
func (*MultiError) ErrorOrNil ¶
func (e *MultiError) ErrorOrNil() error
ErrorOrNil returns the MultiError if errors exist, or nil.
func (*MultiError) HasErrors ¶
func (e *MultiError) HasErrors() bool
HasErrors reports whether any errors were collected.
func (*MultiError) Unwrap ¶
func (e *MultiError) Unwrap() []error
Unwrap returns the collected errors for errors.Is/As traversal.