David.Holmes at oracle.com
Wed Aug 25 03:58:16 PDT 2010
Gernot Neppert said the following on 08/24/10 22:29:
>> Well I disagree that the exception in the try block is necessarily more
>> important than the one in the finally block.
> It might not be more important, but it might be the only one that you
> can spot by looking at the code:
I was referring to try-finally, not try-with.
> try(Reader reader = new FileReader("contents.txt"))
> char buf = new char;
> int read;
> while(0 < (read = reader.read(buf)))
> // Do something
> Wouldn't you want the above block to re-throw exceptions from the
> constructor or from 'read', rather than from an 'invisible' exception
This really is an argument against hiding the code in the first place.
When you read the above you have to implicitly "see" the hidden close
that might also throw an exception.
Regardless of which exception is thrown you will want/need to follow the
chain to get the full picture of what has gone wrong.
> (See also my other post suggesting that the compiler might be more
> helpful in pointing at 'hidden' exception sources)
More information about the coin-dev