catch doesn't catch a thrown exception

catch doesn't catch a thrown exception

Post by Marteno Ro » Tue, 04 Aug 2009 20:09:27


Of course, I don't think it is ever possible, but let me begin from
the start...

I'm using in my program a method delivered to me (let's call it the
"super method") and it uses a few methods from its native packet (a
pretty long list of nested invocations). In some cases, an error
occurs and one of the methods invoked throws a new Error("message")
(not an Exception, but an Error).

I just happen to want to handle this error (it's a little strange,
however, desired in this case), but I encountered quite a big problem:
the try-catch I've put the "super method" in exits normally, without
going into the catch section...

I'm really confused, and I can see only 2 explanations:
1) There is another catch (on a different level of the call stack)
which I didn't notice and the error is handled silently there.
2) There is something I don't know about unchecked exceptions like my
Error class.

1') how to check where the exception/error is really handled? (I've
been looking into the code for hours...)
2') what is that I don't know?
3) is there any other explanation?

MR
 
 
 

catch doesn't catch a thrown exception

Post by markspac » Wed, 05 Aug 2009 00:00:59


Beats me, it should work, I've done it.






SSCCE please.

 
 
 

catch doesn't catch a thrown exception

Post by Alessio St » Wed, 05 Aug 2009 00:08:33


do you catch(Exception) or catch(Error) or...? Error does not extend
Exception ( http://www.yqcomputer.com/
Error.html).

AS
 
 
 

catch doesn't catch a thrown exception

Post by Roedy Gree » Wed, 05 Aug 2009 02:27:49

On Mon, 3 Aug 2009 04:09:27 -0700 (PDT), Marteno Rodia
< XXXX@XXXXX.COM > wrote, quoted or indirectly quoted someone who
said :


I saw a documentary about medicine in ancient China. Women were so
modest they could not disrobe or even talk about their medical
conditions. The best they could do was point at a doll.

You need to post some code to make your complaint clear.
see http://www.yqcomputer.com/
--
Roedy Green Canadian Mind Products
http://www.yqcomputer.com/

"Patriotism is fierce as a fever, pitiless as the grave, blind as a stone, and as irrational as a headless hen."
~ Ambrose Bierce (born: 1842-06-24 died: 1914 at age: 71)
 
 
 

catch doesn't catch a thrown exception

Post by Marcin Rod » Wed, 05 Aug 2009 14:56:08

The Error is thrown, and I try to catch Throwable, so it should be OK.

The code is so enormous that it's no use posting it. If I had chosen
only "important" part, I would have probably omitted the problem,
because the problem was I didn't know where the problem was. The
application contains a few threads, that was the reason I was not sure
how to use de *** . Anyway, I tried to track execution of the
problematic part of the code, and I saw that there is another try-
catch I haven't notice (I'm sure I wouldn't have posted it!)

It is obvious that caught exception is no longer thrown, so the
problem disappeared :)

Anyway, thank to everyone who longed to help me :)
MR
 
 
 

catch doesn't catch a thrown exception

Post by Daniel Pit » Thu, 06 Aug 2009 12:30:07


That is one of the benefits of attempting to construct an SSCCE. If you
can't construct it from the bits of the program you think are causing
the problem, then its actually being caused in the bits you *aren't*
thinking about.

--
Daniel Pitts' Tech Blog: < http://www.yqcomputer.com/ ;