Re-raising exceptions with modified message

Christoph Zwerschke cito at online.de
Thu Jul 5 16:40:41 CEST 2007


Thomas Heller wrote:
> I have the impression that you do NOT want to change the exceptions,
> instead you want to print the traceback in a customized way.  But I may be wrong...

No, I really want to modify the exception, supplementing its message 
with additional information about the state of the program.

The use case are compiled Kid templates (http://kid-templating.org). If 
an error occurs, I want to add the corresponding line number of the XML 
file as information for the template developer. Since the final error 
handling may happen somewhere else (e.g. by TurboGears importing a Kid 
template), I do not want to modify trackeback handling or something.

-- Chris



More information about the Python-list mailing list