Documentation
¶
Index ¶
- func AnyToErr(v any) error
- func DoInBackground(ctx context.Context, fn func(ctx context.Context) error)
- func Must[T any](obj T, err error) T
- func MustNoReturn(err error)
- func MustOk[T any](obj T, ok bool) T
- func WithRecover(f func() error) func() error
- func WithRecoverAndLog(f func(ctx context.Context) error) func(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyToErr ¶
AnyToErr converts a recovered panic value into an error: nil stays nil, an error is wrapped as "panicked", and anything else is formatted into one.
func DoInBackground ¶ added in v1.0.1
DoInBackground runs fn in a new goroutine, recovering panics and logging errors. The goroutine's context keeps ctx's values but is detached from its cancellation and capped with a 3-minute timeout, so fn outlives the caller.
func Must ¶
Must returns obj, or panics if err is non-nil. Use only where an error is a programming error, e.g. package init.
func MustNoReturn ¶
func MustNoReturn(err error)
MustNoReturn panics if err is non-nil, for calls that only return an error.
func MustOk ¶
MustOk returns obj, or panics if ok is false. Handy for the comma-ok forms (map lookup, type assertion).
func WithRecover ¶
WithRecover decorates f so that a panic is recovered and returned as an error wrapped with "recovered"; a normal error from f is returned as-is.
Types ¶
This section is empty.