Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5916
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!cyclone03.ams2.highwinds-media.com!news.highwinds-media.com!npeersf01.ams.highwinds-media.com!newsfe18.ams2.POSTED!00000000!not-for-mail |
|---|---|
| From | John J Lee <jjl@pobox.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: List of WindowsError error codes and meanings |
| References | <mailman.1847.1305914213.9059.python-list@python.org> |
| Message-ID | <8762p48eel.fsf@pobox.com> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:/SvDK0G9fOcjB8M5GVQIuXKUEPs= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Lines | 34 |
| NNTP-Posting-Host | 82.44.73.236 |
| X-Complaints-To | http://netreport.virginmedia.com |
| X-Trace | newsfe18.ams2 1305978394 82.44.73.236 (Sat, 21 May 2011 11:46:34 UTC) |
| NNTP-Posting-Date | Sat, 21 May 2011 11:46:34 UTC |
| Organization | virginmedia.com |
| Date | Sat, 21 May 2011 12:46:26 +0100 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:5916 |
Show key headers only | View raw
Andrew Berg <bahamutzero8825@gmail.com> writes:
> This is probably somewhat off-topic, but where would I find a list of
> what each error code in WindowsError means? WindowsError is so broad
> that it could be difficult to decide what to do in an except clause.
> Fortunately, sys.exc_info()[1][0] holds the specific error code, so I
> could put in an if...elif...else clause inside the except clause if I
> needed to, but I don't know what all the different errors are.
Since Python 2.5, the errno attribute maps the Windows error to error
codes that match the attributes of module errno.
http://docs.python.org/library/exceptions.html#exceptions.WindowsError
So for some purposes you can use the same UNIXy error codes you can use
on most other platforms. Example:
import errno
try:
operation()
except WindowsError, exc:
if exc.errno != errno.ENOENT:
raise
print "file/directory does not exist"
Obviously whether this is useful depends on the error cases you need to
handle.
Undocumented: when there's no useful mapping to errno, you get
errno.EINVAL.
John
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-20 12:56 -0500
Re: List of WindowsError error codes and meanings Genstein <genstein@invalid.invalid> - 2011-05-20 20:47 +0100
Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-20 16:55 -0500
Re: List of WindowsError error codes and meanings John J Lee <jjl@pobox.com> - 2011-05-21 12:46 +0100
Re: List of WindowsError error codes and meanings Genstein <genstein@invalid.invalid> - 2011-05-21 16:35 +0100
Re: List of WindowsError error codes and meanings John Lee <jjl@pobox.com> - 2011-05-22 17:55 +0000
Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-22 09:35 -0500
Re: List of WindowsError error codes and meanings Thomas Heller <theller@ctypes.org> - 2011-05-26 17:02 +0200
Re: List of WindowsError error codes and meanings Andrew Berg <bahamutzero8825@gmail.com> - 2011-05-27 04:22 -0500
csiph-web