How many times have you written the following code:
1
2
3
4
5
6
7
| void someMethod() throws X1,X2 {
try { /* Something that can throw X1,X2 */ }
catch (Throwable e) {
logger.log(e);
throw e; // Error: Unreported exception Throwable
}
}
|
Need a way to express we are simply re-throwing the Exception that
was caught.
The Proposal to add the safe re-throw to the language is as follows:
1
2
3
4
5
6
7
| void m() throws X1,X2 {
try { /* Something that can throw X1,X2 */ }
catch (final Throwable e) {
logger.log(e);
throw e; // Compiles OK; can throw X1,X2
}
}
|
Again, lets hope it makes its way in to Java 7.