SUMMARY: Re: Parsing exceptions the pythonic way

Hal Wine hal_wine at yahoo.com
Fri May 30 11:02:38 EDT 2003


Hal Wine wrote:
> It seems this should be easier and cleaner than I've figured out, so I 
> guess I don't know python very well yet :(
> 
> What's the pythonic way to get error numbers or base messages from an 
> exception?  Solution need only work for standard library.

As a wrap up -- there is no standard way to handle accessing the 
internals of exception instances. One has to dig around in 
various bits of code to find out how the exception data is being 
built, and do some case specific extraction.

In my specific example of urllib.urlopen, it turned out that 
subclassing URLopener and overriding the default error method was 
the simplest solution.

--Hal





More information about the Python-list mailing list