2 ms·
Yah, I've always felt that the "checked" should not have been part of the exception type, rather it should have been part of the throw: throw checked new E
by ars 4y ago
Yah, I've always felt that the "checked" should not have been part of the exception type, rather it should have been part of the throw:
throw checked new Exception();
Then the caller knows there is a special reason to handle this exception, and it's also easy to write a tiny wrapper to neutralize the check, if needed.
For example: failure to open a file could be nothing major in one case (just return null), needs to be handled in another, or should cause the entire application to exit. This depends on what file was opened - but it does NOT depend on the type of error.