Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Crash ¶
func Crash(v interface{})
Crash calls registry's internal Crash function to invoke registered panic handler.
func Go ¶
func Go(f func())
Go calls registry's internal Go function to start f on a new go routine.
func RegisterPanicHandler ¶
func RegisterPanicHandler(ph PanicHandler)
RegisterPanicHandler calls global registry's internal register panic handler function to panic handler registry.
func RegisterPanicHandlers ¶
func RegisterPanicHandlers(in PanicHandlerRegistryIn)
RegisterPanicHandlers register panic handlers to panic handler registry.
Types ¶
type Callstack ¶
type Callstack []uintptr
Callstack is a full stacktrace.
func (Callstack) GetEntries ¶
GetEntries returns stacktrace of Callstack in map[string]interface{} format.
type Entry ¶
type Entry struct { // Location holds the physical location for this entry. Location Location // Location holds the logical location for this entry. Function Function // PC is the program counter for this entry. PC uintptr }
Entry holds the human understandable form of a StackTrace entry.
type Function ¶
type Function struct { // Package is the go package the stack entry is from. Package string // Name is the function name the stack entry is from. Name string }
Function holds the logical location of a stack entry.
type Location ¶
type Location struct { // Directory is the directory the source file is from. Directory string // File is the filename of the source file. File string // Line is the line index in the file. Line int }
Location holds the physical location of a stack entry.
type PanicHandler ¶
type PanicHandler func(interface{}, Callstack)
PanicHandler is a panic handling function that is called when a panic occurs with full stacktrace.
type PanicHandlerOut ¶
type PanicHandlerOut struct { fx.Out PanicHandler PanicHandler `group:"panic-handlers"` }
PanicHandlerOut enables registering panic handlers via Fx.
type PanicHandlerRegistry ¶
type PanicHandlerRegistry struct { Handlers []PanicHandler // contains filtered or unexported fields }
PanicHandlerRegistry defines a list of panic handlers.
func (*PanicHandlerRegistry) Crash ¶
func (r *PanicHandlerRegistry) Crash(v interface{})
Crash invokes each of the registered panic handler and then rethrows panic - shutting down the app.
func (*PanicHandlerRegistry) Go ¶
func (r *PanicHandlerRegistry) Go(f func())
Go calls f on a new go-routine, reporting panics to the registered handlers.
func (*PanicHandlerRegistry) RegisterPanicHandler ¶
func (r *PanicHandlerRegistry) RegisterPanicHandler(ph PanicHandler)
RegisterPanicHandler appends panic handler to list of global registry's panic handler.
type PanicHandlerRegistryIn ¶
type PanicHandlerRegistryIn struct { fx.In Handlers []PanicHandler `group:"panic-handlers"` }
PanicHandlerRegistryIn holds parameters, list of panic handlers, for RegisterPanicHandlers.