3 ms·
Wrapping exceptions when re-throwing can be really useful. I think that this feature is often underused, especially by people who complain about checked excepti
by gmueckl 6y ago
Wrapping exceptions when re-throwing can be really useful. I think that this feature is often underused, especially by people who complain about checked exceptions.
- ragnese 6y agoI suspect that most Java devs have literally never considered anything beyond "Handle it here or rethrow it as-is".
- singron 6y agoE.g. Future wraps any Throwable in ExecutionException, which is a checked exception. But ExecutionExeption could wrap any exception! It may as well just throw Exception. I really would have loved e.g. Future<Value,IOException|FooException>. Obviously it gets erased in the executor, but if your code holds on to it, it could maintain checked exceptions over the async boundary.