From 78895e6943978d3922639f8162e148b8c60ad143 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 19 Jan 2012 01:30:46 +0000 Subject: [PATCH] Added doc for Error.cursor --- doc/src/module.rst | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/doc/src/module.rst b/doc/src/module.rst index 29f4b636..5a2496cb 100644 --- a/doc/src/module.rst +++ b/doc/src/module.rst @@ -117,31 +117,30 @@ available through the following exceptions: if not available. The `~psycopg2.errorcodes` module contains symbolic constants representing PostgreSQL error codes. + .. doctest:: + :options: +NORMALIZE_WHITESPACE + + >>> 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 + ^ + .. attribute:: cursor + + The cursor the exception was raised from; `None` if not applicable. + .. extension:: - The `~Error.pgerror` and `~Error.pgcode` attributes are - Psycopg extensions. - - .. doctest:: - :options: +NORMALIZE_WHITESPACE - - >>> 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 `Error.pgerror` and - `Error.pgcode` attributes. + The `~Error.pgerror`, `~Error.pgcode`, and `~Error.cursor` attributes + are Psycopg extensions. - .. exception:: InterfaceError Exception raised for errors that are related to the database interface