Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Thomas Heller Newsgroups: comp.lang.python Subject: Re: List of WindowsError error codes and meanings Date: Thu, 26 May 2011 17:02:30 +0200 Lines: 29 Message-ID: <9478c6Fr09U1@mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net TcYZr5sJV5WnhrhTtpTO3Awimjltsdz0uS+Zc1zXnwBPOCjG4= Cancel-Lock: sha1:1oLk6/nKmMyU/GRwP7WuQJtWF+U= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:6320 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 "", line 1, in OverflowError: long int too large to convert to int >>> ctypes.FormatError(0x80040005 - (2**32-1)) 'Kein Cache zum Verarbeiten vorhanden.' >>> Thomas