Documentation
¶
Overview ¶
Package handler implements handler for objects returned recovery() function.
Index ¶
- func LogOutput(lvl int, s string) (err error)
- func NilNoop(err error) error
- func NoerrCallToDo(a ...any) (yes bool)
- func PanicNoop(any)
- func PreProcess(errPtr *error, info *Info, a ...any) error
- func Process(info *Info)
- func WorkToDo(r any, err *error) bool
- type CheckHandler
- type ErrorHandler
- type Info
- type NilHandler
- type PanicHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoerrCallToDo ¶ added in v0.9.5
func PreProcess ¶ added in v0.8.12
PreProcess is currently used for err2 API like err2.Handle and .Catch.
- replaces the Process
func Process ¶
func Process(info *Info)
Process executes error handling logic. Panics and whole defer stack is included.
- err2.API functions call PreProcess and Process is exported for tests.
- That there is an error or a panic to handle i.e. that's taken care.
Types ¶
type CheckHandler ¶ added in v0.9.5
type CheckHandler = func(noerr bool)
CheckHandler = func(noerr bool, err error) error
type ErrorHandler ¶
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). ErrorHandler // If nil default implementation is used. NilHandler // If nil default (pre-defined here) implementation is used. PanicHandler // If nil panic() is called. CheckHandler // this would be for cases where there isn't any error, but CallerName string // contains filtered or unexported fields }
Info tells to Process function how to proceed.
type NilHandler ¶
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.