func someFunc() (err error) {
defer func(err_ error) {
r.handleErrOrPanic(err_, obj)
}(err) // err is always nil here
err = ThrowErrOrPanic(ctx, obj)
return err
}
I would like to use handleErrOrPanic
as a deferred function to handle the error or the panic. I have to define it before ThrowErrOrPanic
, since the deferred function has to handle the panic. However, if I define it before err
is always nil. How do I solve this?