Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #6380

Re: List of WindowsError error codes and meanings

Date 2011-05-27 04:22 -0500
From Andrew Berg <bahamutzero8825@gmail.com>
Subject Re: List of WindowsError error codes and meanings
References <mailman.1847.1305914213.9059.python-list@python.org> <9478c6Fr09U1@mid.individual.net>
Newsgroups comp.lang.python
Message-ID <mailman.2148.1306488176.9059.python-list@python.org> (permalink)

Show all headers | View raw


On 2011.05.26 10:02 AM, Thomas Heller wrote:
> 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.'
>  >>>
I could get that with str(sys.exc_info()[1]), though. If something
raises a WindowsError, str(sys.exc_info()[1]) contains something like:
[Error 183] Cannot create a file when that file already exists:
<file/directory>

sys.exc_info() is how I get the error code from inside an except clause
in the first place. Or is there something I'm missing here?

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


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