safe

package
v0.0.0-...-80d8d71 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Catcher

type Catcher struct {
	// contains filtered or unexported fields
}

Catcher handles safely catching the panic. Use `Try` instead of this class direction.

func (*Catcher) Caught

func (p *Catcher) Caught() *RecoveredPanic

func (*Catcher) Rethrow

func (p *Catcher) Rethrow()

Rethrow will panic with the caught RecoveredPanic. If no panic was recovered then this is a no-op.

func (*Catcher) Try

func (p *Catcher) Try(fn func())

Try calls the given function and recovers from any panic. If a panic is not raised, the returned value will be nil.

type RecoveredPanic

type RecoveredPanic struct {
	Value      any
	DebugTrace []byte
	// contains filtered or unexported fields
}

func Try

func Try(fn func()) *RecoveredPanic

Try calls the given function and recovers from any panic. If a panic is not raised, the returned value will be nil.

func (*RecoveredPanic) Error

func (p *RecoveredPanic) Error() error

Error returns a RecoveredPanicError It is safe to call this on a nil value and the result will be nil.

func (*RecoveredPanic) String

func (p *RecoveredPanic) String() string

type RecoveredPanicError

type RecoveredPanicError struct {
	RecoveredPanic
}

func AsRecoveredPanicError

func AsRecoveredPanicError(err error) *RecoveredPanicError

func (*RecoveredPanicError) Error

func (p *RecoveredPanicError) Error() string

func (*RecoveredPanicError) StackTrace

func (p *RecoveredPanicError) StackTrace() pkgErr.StackTrace

func (*RecoveredPanicError) Unwrap

func (p *RecoveredPanicError) Unwrap() error

type StackTraceProvider

type StackTraceProvider interface {
	StackTrace() pkgErr.StackTrace
}

Jump to

Keyboard shortcuts

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