Error Codes From a URLError

Fuzzyman michael at foord.net
Sat Jul 24 03:44:21 EDT 2004


Christopher T King <squirrel at WPI.EDU> wrote in message news:<Pine.LNX.4.44.0407231202530.29684-100000 at ccc8.wpi.edu>...
> On 23 Jul 2004, Fuzzyman wrote:
> 
> > *However*, when I use it to try to fetch a non-existent page
> > (expecting a 404 error) - it falls at the first raise statement.
> > Evidently the exception *is* an IOError, but doesn't have the code
> > attribute.
> 
> For the "non-existent page", are you using a url of the form
> 'http://fake.server/some/file' or 'http://real.server/fake/file'?  
> Because if the host is nonexistent (and therefore a connection can't be
> opened), then I'd expect urllib2 to raise an IOError.  I'd expect an
> HTTPError only if the server exists and explicitly returns a 404.

Right - that would explain it.
But it makes it difficult to trap the errors - an IOError *might* mean
the page is non-existent... *or* it might mean another problem !!

Oh well.

Thanks

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list