How to know more about an exception?

T

Timmy

Hi,
I has a question about exception in python.
I know that an exception can be re-raised.
Is there any simple way provided by python itself that I can know the current exception is
just firstly occurred or it is re-raised by previous exception?
I need to know whether the exception is firstly occurred or not because I want to just display an error message if it's
firstly occur and skip display error message if it is just re-raised by previous exception.

Thanks!
 
D

Diez B. Roggisch

Timmy said:
Hi,
I has a question about exception in python.
I know that an exception can be re-raised.
Is there any simple way provided by python itself that I can know the current exception is
just firstly occurred or it is re-raised by previous exception?
I need to know whether the exception is firstly occurred or not because I want to just display an error message if it's
firstly occur and skip display error message if it is just re-raised by previous exception.

No, that's not possible. What you can do is either

- wrap the exception instead of re-raising it

- set some property on the exception before re-raising.


Diez
 

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

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top