Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPanicRecovery = errors.New("cannot safecall function: recovered from a panic") ErrInvalidFunction = errors.New("cannot safecall function: first argument is not a function") ErrIncorrectArguments = errors.New("cannot safecall function: number of arguments does not match function's input arity") ErrMoreThanTwoReturns = errors.New("cannot safecall function: function returns more than two values") ErrInvalidLastReturnType = errors.New("cannot safecall function: invalid last return type (expected error)") )
Functions ¶
func SafeCall ¶
SafeCall safely calls a function using reflection. It handles potential panics by recovering and returning an error. The function `fn` is expected to be a function, and `args` are the arguments to pass to that function. It returns the result of the function call (if any) and an error if one occurred during the call or if a panic was recovered.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.