Re: How to call TPyException in Python?

From: <wlavrijsen_at_lbl.gov>
Date: Wed, 4 May 2011 11:19:33 -0700


Akira,

> According to your explanation, it seems that my own exception classes
> derived from std::exception are not useful because they are all turned
> into single class, Exception. Therefore, if I want to distinguish different
> type of errors (exceptions) from each other, I always have to check
> Exception.message in if statement instead of try statement. Am I correct?

that is the case. I can fix that for the known exceptions that map nicely onto python ones, and I can probably even add the type name, but I guess what you want is a downcast of the exception to the actual type, check whether there's a dictionary available and then turn it into that type on the python side?

Not impossible, just scary to put a lot of work inside a catch block of an exception handler. :} (If something else goes wrong and there is a second exception, the application would terminate.)

Best regards,

            Wim

-- 
WLavrijsen_at_lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net
Received on Wed May 04 2011 - 20:19:42 CEST

This archive was generated by hypermail 2.2.0 : Wed May 04 2011 - 23:50:01 CEST