Documentation
¶
Overview ¶
Package handler implements handler for objects returned recovery() function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PreProcess ¶ added in v0.8.12
func Process ¶
func Process(info *Info)
Process executes error handling logic. Panics and whole defer stack is included.
Types ¶
type ErrorHandler ¶
type ErrorHandler = func(err error)
type Info ¶
type Info struct {
Any any // panic transport object
Err *error // error transport pointer (i.e. in/output)
Format string // format string
Args []any // args for format string printing
// These are used if handler.Process caller sets them. If they aren't set
// handler uses package level variables from tracer.
ErrorTracer io.Writer // If nil tracer package's default is used.
PanicTracer io.Writer // If nil tracer package's default is used.
// These are called if handler.Process caller sets it. If they aren't set
// default implementations are used. NOTE. We have to use both which means
// that we get nilHandler call if recovery() is called by any other
// handler then we call still ErrorHandler and get the error from Any. It
// goes for other way around: we get error but nilHandler is only one to
// set, we use that for the error (which is accessed from the closure).
NilHandler // If nil default implementation is used.
ErrorHandler // If nil default implementation is used.
PanicHandler // If nil panic() is called.
}
Info tells to Process function how to proceed.
type NilHandler ¶
type NilHandler = func()
type PanicHandler ¶
type PanicHandler = func(p any)
we want these to be type aliases, so they are much nicer to use
Click to show internal directories.
Click to hide internal directories.