News for hackers. Stuff that matters.
Re:Software development topics I've changed my mind on after... by lmm on Wednesday February 05, 2025 @09:52AM (#42949245)
> 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.

There are no comments on this comment yet.