Am 20.05.2011 19:56, schrieb Andrew Berg:
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.

On Windows, you can use ctypes.FormatError(code) to map error codes
to strings:

>>> import ctypes
>>> ctypes.FormatError(32)
'Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.'
>>>

For HRESULT codes, you (unfortunately) have to subtract 2**32-1 from
the error code:

>>> ctypes.FormatError(0x80040005)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to int
>>> ctypes.FormatError(0x80040005 - (2**32-1))
'Kein Cache zum Verarbeiten vorhanden.'
>>>

Thomas
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to