Make the signature of your generic callback "throws Throwable". It's generic; it should never care about the specific types that the callback can throw.
(Except that then you have to decide what your generic function is going to do if the callback throws an exception...)
> Make the signature of your generic callback "throws Throwable". It's generic; it should never care about the specific types that the callback can throw.
> (Except that then you have to decide what your generic function is going to do if the callback throws an exception...)
Exactly. Presumably you don't want to handle them and want to throw them up to the caller. But now your function has to be "throws Throwable" rather than throwing the specific exception types that the callback throws.
By doing that you lose all the benefits of checked exceptions. If you have checked exceptions everywhere the compiler will tell you when an exception is not handled and in turn you can ensure you handle it.
Of course in general the manual effort to do that in a large code base ends up too hard and so in the real world nobody does that. Still the ideal is good, just the implementation is flawed.
(Except that then you have to decide what your generic function is going to do if the callback throws an exception...)