Obviously I'm being terse for argument.
You can easily imagine
InvokeWithErrorLogger(fn, fnparam, log)
InvokeWithErrorAnnotator(fn, fnparam, annotatorFn)
Perhaps something like this?
result := InvokeWithErrorLogger( func (err error) { // Error handler incrementMetric("foo") log.Error("bar") }, addTwoNumbers, a, b, )
result, err := addTwoNumbers(a, b) if err != nil { incrementMetric("foo") log.Error("bar") return fmt.Errorf("addTwoNumbers(%d, %d) = %v", a, b, err) }
Perhaps something like this?
But the problem is that this approach is not better than just writing this, which doesn't need any new fancy addition to the language: Hence why all the proposals ended up dying with the lack of traction.