Message170710
| Author |
ezio.melotti |
| Recipients |
amaury.forgeotdarc, catherine, ezio.melotti, georg.brandl, orsenthil, r.david.murray |
| Date |
2012年09月19日.07:51:05 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1348041065.85.0.49438838444.issue6471@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> I seem to remember writing code that fished the wrapped error
> out using one of those attributrs...
That would be err.reason:
from urllib.request import urlopen
try:
urlopen('http://www.pythonfoobarbaz.org')
except Exception as exc:
print('err:', err)
print('repr(err):', repr(err))
print('err.reason:', err.reason)
print('repr(err.reason):', repr(err.reason))
prints:
err: <urlopen error [Errno -2] Name or service not known>
repr(err): URLError(gaierror(-2, 'Name or service not known'),)
err.reason: [Errno -2] Name or service not known
repr(err.reason): gaierror(-2, 'Name or service not known') |
|