`errors` -- Package exceptions
==============================
+.. module:: psycopg.errors
+
.. index::
single: Error; Class
-.. module:: psycopg
-
This module exposes objects to represent and examine database errors.
-.. autoexception:: Error()
-
- .. autoattribute:: diag
-
-
-.. module:: psycopg.errors
-
-.. autoclass:: Diagnostic()
-
- The object is returned by the `Error.diag` attribute and is passed to the
- callback functions registered with
- `~psycopg.Connection.add_notice_handler()`.
-
- All the information available from the :pq:`PQresultErrorField()` function
- are exposed as attributes by the object. For instance the `!severity`
- attribute returns the `!PG_DIAG_SEVERITY` code. Please refer to the
- PostgreSQL documentation for the meaning of all the attributes.
-
- The attributes available are:
-
- .. attribute::
- column_name
- constraint_name
- context
- datatype_name
- internal_position
- internal_query
- message_detail
- message_hint
- message_primary
- schema_name
- severity
- severity_nonlocalized
- source_file
- source_function
- source_line
- sqlstate
- statement_position
- table_name
-
- A string with the error field if available; `!None` if not available.
- The attribute value is available only for errors sent by the server:
- not all the fields are available for all the errors and for all the
- server versions.
-
.. currentmodule:: psycopg
These classes are exposed both by the Psycopg and the `!psycopg.errors`
module.
+.. autoexception:: Error()
+
+ .. autoattribute:: diag
+
.. autoexception:: Warning()
.. autoexception:: InterfaceError()
.. autoexception:: DatabaseError()
.. _sqlstate-exceptions:
+
+Error diagnostics
+-----------------
+
+.. autoclass:: Diagnostic()
+
+ The object is returned by the `Error.diag` attribute and is passed to the
+ callback functions registered with
+ `~psycopg.Connection.add_notice_handler()`.
+
+ All the information available from the :pq:`PQresultErrorField()` function
+ are exposed as attributes by the object. For instance the `!severity`
+ attribute returns the `!PG_DIAG_SEVERITY` code. Please refer to the
+ PostgreSQL documentation for the meaning of all the attributes.
+
+ The attributes available are:
+
+ .. attribute::
+ column_name
+ constraint_name
+ context
+ datatype_name
+ internal_position
+ internal_query
+ message_detail
+ message_hint
+ message_primary
+ schema_name
+ severity
+ severity_nonlocalized
+ source_file
+ source_function
+ source_line
+ sqlstate
+ statement_position
+ table_name
+
+ A string with the error field if available; `!None` if not available.
+ The attribute value is available only for errors sent by the server:
+ not all the fields are available for all the errors and for all the
+ server versions.
+
+
SQLSTATE exceptions
-------------------