Notification on Exceptions

  • Thread starter Thread starter Rakesh
  • Start date Start date
R

Rakesh

Hi,

I would like a method to get invoked whenever an
exception is thrown in my Main thread, even if it is
caught. Is there any automated way to do this without
calling it explicitly in all catch blocks?

Thanks in advance
Rakesh
 
You have two chioces if I understand the problem correctly. 1) Don't
include try catches and let the exception propogate up to one that you wrap
around main 2) Rethrow your exceptions in the local blocks so they
propogate back up the stack. Another alternative is to create your own
subclassed exception(s) and call them, in that/those classes, raise whatever
event you want. This is a cumbersome approach and probably isn't worth it,
but it may suit your needs. More than likely you'll want to opt for one of
the first two methods.. probably the second.

HTH,

Bill
 
You will need to add try catch blocks to all your event
handler code. The catch blocks shld all have one method
where you want to do your event handling. That way any
unhandled exception gets trapped and handled in one method
of your choice.

Cheers, MTK.
 
Back
Top