Java lost exception -


suppose have following method (a simplified version):

    void dosomething() {       try {         throw new exception("a");       } {         throw new exception("b");       }     } 

exception message "b" caught in caller method. basically, there way of knowing exception thrown in try block if block throws exception? suppose method dosomething() cannot modified.

section 14.20.2 of jls states:

if execution of try block completes abruptly because of throw of value v, ...

...

if block completes abruptly reason s, try statement completes abruptly reason s (and throw of value v discarded , forgotten).

java must discard original exception v ("complete abruptly") , whole try-finally block "completes abruptly" s (the finally exception, "b").

there no way retrieve original try block exception "a", corresponds v in jls.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

c# - How do I get the Nth largest element from a list with duplicates, using LINQ? -

jsp - "Sending a redirect is forbidden after the response has been committed" in sendRedirect -