From e4d427aae62e48fa7f5045a7a5c2edeab03c217b Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Sat, 13 Feb 2010 05:44:49 +0000 Subject: [PATCH] Added documentation for 'Error.pgerror' and 'Error.pgcode' attributes. --- doc/module.rst | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/module.rst b/doc/module.rst index 6fe52208..be3bfe31 100644 --- a/doc/module.rst +++ b/doc/module.rst @@ -92,6 +92,39 @@ available through the following exceptions: use this to catch all errors with one single ``except`` statement. Warnings are not considered errors and thus should not use this class as base. It is a subclass of the Python |StandardError|_. + + .. attribute:: pgerror + + String representing the error message returned by the backend, + ``None`` if not available. + + .. attribute:: pgcode + + String representing the error code returned by the backend, ``None`` + if not available. The :mod:`~psycopg2.errorcodes` module contains + symbolic constants representing PostgreSQL error codes. + + .. extension:: + + The :attr:`~Error.pgerror` and :attr:`~Error.pgcode` attributes are + Psycopg extensions. :: + + >>> try: + ... cur.execute("SELECT * FROM barf") + >>> except Exception, e: + .... pass + + >>> e.pgcode + >>> '42P01' + >>> print e.pgerror + ERROR: relation "barf" does not exist + LINE 1: SELECT * FROM barf + ^ + + .. versionchanged:: 2.0.7 added :attr:`Error.pgerror` and + :attr:`Error.pgcode` attributes. + + .. exception:: InterfaceError