How to tell if an exception has been caught ( from inside theexception )?

P

Paul Dale

Hi everyone,

I'm writing an exception that will open a trouble ticket for certain
events. Things like network failure. I thought I would like to have it
only open a ticket if the exception is not caught. Is there a way to do
this inside the Exception? As far as I can see there are only two events
called on the exception, __init__ and __del__, both of which will be
called wether or not an exception is caught (right?)

Am I missing something, or is there a way to do this with exceptions?

Thanks!

Paul
 
R

Rocco Moretti

Paul said:
Hi everyone,

I'm writing an exception that will open a trouble ticket for certain
events. Things like network failure. I thought I would like to have it
only open a ticket if the exception is not caught. Is there a way to do
this inside the Exception? As far as I can see there are only two events
called on the exception, __init__ and __del__, both of which will be
called wether or not an exception is caught (right?)

Am I missing something, or is there a way to do this with exceptions?

Is there some reason you can't wrap your entry point with a try:except?

e.g.

if __name__ == "__main__":
try:
main()
except OpenTicket, e:
process_open_ticket(e)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top