handler

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package handler implements handler for objects returned recovery() function.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NilNoop added in v0.8.12

func NilNoop()

func PanicNoop added in v0.8.12

func PanicNoop(_ any)

func PreProcess added in v0.8.12

func PreProcess(info *Info, a ...any)

PreProcess is currently used for err2.Handle.

NOTE! That there is an error or a panic to handle i.e. that's taken care.

func Process

func Process(info *Info)

Process executes error handling logic. Panics and whole defer stack is included.

NOTE! That there is an error or a panic to handle i.e. that's taken care.

func WorkToDo added in v0.8.12

func WorkToDo(r any, err *error) bool

WorkToDo returns if there is something to process. This is offered for optimizations. Starting and executing full error handler stack with the tracers and other stuff is heavy. This function offers us a API to make the decision to abort the processing ASAP.

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.

	CallerName string
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL