Documentation
¶
Overview ¶
Package pantoerr (panic to error) provides methods that wrap functionality and recover from panics returing errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRecoveredPanicCause ¶
func GetRecoveredPanicCause(err error) interface{}
func IsRecoveredPanic ¶
func PanicToError ¶
Runs the function given, recovering from any panics and returning a RecoveredPanic error with the errMsg given. The function can optionally return an error of its own, which will be returned in the non-panic case.
func PanicToErrorInstance ¶
Runs the function given, recovering from any panics and returning the given error instance instead. The function can optionally return an error of its own, which will be returned in the non-panic case.
func PanicToErrorNil ¶
Same as PanicToError, but for functions that don't return errors except in the case of panic.
Types ¶
type RecoveredPanic ¶
type RecoveredPanic struct {
PanicCause interface{}
ErrMsg string
}
RecoverPanic is used to convert panics to errors. The attic-labs noms codebase loves to panic. This is not idiomatic for Go code. RecoverPanic wraps the cause of the panic retrieved from the recover call, and implements the error interface so it can be treated like a standard error.
func (*RecoveredPanic) Error ¶
func (rp *RecoveredPanic) Error() string
Error returns the error message