Re-raising exceptions with modified message

Christoph Zwerschke cito at online.de
Sun Jul 8 15:53:51 CEST 2007


samwyse wrote:
> def test(code):
>   try:
>     code()
>   except Exception, e:
>     try:
>       raise e.__class__, str(e) + ", sorry!"
>     except TypeError:
>       raise SorryFactory(e)()

Ok, you're suggestig the naive approach if it works and the factory 
approach I came up with last as a fallback. Maybe a suitable compromize.

-- Chris



More information about the Python-list mailing list