Python error codes and messages location
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sun May 26 20:53:41 EDT 2013
On Mon, 27 May 2013 02:13:54 +0300, Carlos Nepomuceno wrote:
> Where can I find all error codes and messages that Python throws (actual
> codes and messages from exceptions raised by stdlib)?
There is no list. It is subject to change from version to version,
including point releases.
Many functions and methods document which exceptions they can be expected
to raise, or at least the *usual* exceptions, but many more do not. And
the error messages themselves are implementation details and are subject
to change without notice, even if the exception type is a documented part
of the API.
You can see a full list of built-in exception types in the docs:
http://docs.python.org/3/library/exceptions.html
but of course since they are classes, they can be subclassed, and in
principle a function that raises (say) ValueError might sometimes raise a
subclass of ValueError without documenting it.
So the actual answer to your question is:
"Read the source code."
Sorry :-(
> I've already found the module 'errno' and got a dictionary
> (errno.errorcode) and some system error messages
> (os.strerror(errno.ENAMETOOLONG)) but there's more I couldn't find.
These are the standard C operating system and file system error codes,
not Python exceptions.
--
Steven
More information about the Python-list
mailing list