Fixed doc example about Error attributes

Catch the Error, not everything!

Also, whitespaces.
This commit is contained in:
Daniele Varrazzo 2014-08-24 14:57:26 +01:00
parent cafae16072
commit 3775a9d95d

View File

@ -150,7 +150,7 @@ available through the following exceptions:
>>> try:
... cur.execute("SELECT * FROM barf")
... except Exception, e:
... except psycopg2.Error as e:
... pass
>>> e.pgcode
@ -159,6 +159,7 @@ available through the following exceptions:
ERROR: relation "barf" does not exist
LINE 1: SELECT * FROM barf
^
.. attribute:: cursor
The cursor the exception was raised from; `None` if not applicable.
@ -170,7 +171,7 @@ available through the following exceptions:
>>> try:
... cur.execute("SELECT * FROM barf")
... except Exception, e:
... except psycopg2.Error, e:
... pass
>>> e.diag.severity