Disambiguating empty catch blocks

Bruce Chapman brucechapman at paradise.net.nz
Wed Apr 14 09:42:48 UTC 2010


Dimitris Andreou wrote:
> Usual idioms:
>
> 1) catch (Exception ignored) { }
>
> 2) catch (Exception e) { throw new AssertionError(e); }
That constructor doesn't exist (yet)
>
> Also, your impossible() method's signature is not quite right. It 
> should be returning some unchecked exception, so the calling code 
> could write "throw e.impossible();" - even if this statement would 
> never be called, and the exception is thrown from the impossible() 
> method, still this is needed in order not to confuse the compiler 
> (otherwise it would think the subsequent code could be reachable).
>
Good point.

Thanks
> Regards,
> Dimitris




More information about the core-libs-dev mailing list