Combined error message for user defined exceptions

guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam guido-dot-treutwein-at-nbg-dot-siemens-dot-de.cut-here at no.spam
Tue Feb 27 10:07:07 EST 2001


Hi there,

I finally converted my exceptions from string-based to class-based, but
I'm not yet happy with the information in the error traceback.

What I did:

class excMyError(TypeError):
    def __str__(self):
        return "My generic error"
#... and later ...
raise excMyError, "additional info"

What I want is to merge the generic exception text with the additional
information just like

NameError: There is no variable named 'undefvar'

where 'undefvar' corresponds to "additionalInfo" and the rest to the
generic information.
The obvious way (adding a parameter to __str__) failed, what to do else?

Regards



More information about the Python-list mailing list