List of All Error Menssages

Dieter Maurer dieter at handshake.de
Fri Oct 2 12:30:37 EDT 2020


Luis Gustavo Araujo wrote at 2020-10-1 16:06 -0300:
>Is it possible to get the list of all error messages that display in
>Python? I want the full message -> type error: additional message.
>
>Examples:
>NameError: name 'x' is not defined
>IndentationError: unindent does not match any outer indentation level

Some systems indicates errors with an error code (often a number).
If they in addition do not include an error description, you
need a list mapping codes to description.

Python indicates errors via exceptions, documented in the Python
documentation (as far as used by Python; applications may define/derive
further exceptions). In addition, error reports are usually
made descriptive.
An example is `NameError: name 'x' is not defined`: it informs
you about a problem with the name `x`. In addition, you usually
get a traceback - which tells you where in the code the problem
was detected and the (function call) context that led to the problem.
This wealth of direct information removes the need to have
an error list.

In addition: the additional information (beside the exception type)
depends on the concrete situation: it is impossible to list
it beforehand.

>In this webpage (https://docs.python.org/3/library/exceptions.html) I only
>can check the type error.

`exceptions.html` describes Python's exception type hierarchy
(note: Python is object oriented and exceptions are organized into
a class hierarchy) and the exception types used by Python itself.

As you have found out, this describes only the exception types.
When an exception occurs, the type is usally enhanced by
a speaking error description, often including information
about your application entities involved in the exception,
e.g.
>>> open("abc")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'abc'
```
It tells you clearly (and without the need for any list):
the problem was that a file could not have been opened
and that this file was named 'abc'.

Read error messages carefully -- they are usually "speaking".
Should you get a message you do not understand, ask here.
Otherwise, forget about lists of error messages.




More information about the Python-list mailing list