| Author |
throwing exception from finally block (try-finally clause without catch block)
|
Gasan Guseynov
Ranch Hand
Joined: Jan 03, 2006
Posts: 67
|
|
Hi all.
Here is the code example:
And my question is: what's happening with "e" exception? It seems that jvm completely forgot about it.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
Yes, that's one way of describing it. As you found out, the exception thrown in the finally block replaces the exception thrown in the try block. There can only be one exception thrown by a method, of course, so it's necessary to choose one. The choice is: the last one thrown.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24081
|
|
|
As a result, most people consider it very bad style to throw an exception -- or allow one to be thrown -- from a finally block.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Gasan Guseynov
Ranch Hand
Joined: Jan 03, 2006
Posts: 67
|
|
|
Many thanks all. It's very usefull information.
|
 |
 |
|
|
subject: throwing exception from finally block (try-finally clause without catch block)
|
|
|