Documentation ¶
Overview ¶
Package pan (short for panic) can be used to implement internal error propagation via panic and recover. A benefit over naive panic/recover usage is that runtime errors and other unrelated panics are disregarded.
Example
import "import.name/pan" func check(err error) { pan.Check(err) } func checked[T any](x T, err error) T { pan.Check(err); return x } func internal() string { check(os.Chdir("/nonexistent")) return checked(os.Getwd()) } func Public() (s string, err error) { err = pan.Recover(func() { s = internal() }) return }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(x interface{}) error
Error returns an error if x is a panic value from Check. If x is nil, nil is returned. If x is something else, Error panics with x as the panic value.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.