mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-12-01 13:13:45 +03:00
Fixed doc example about Error attributes
Catch the Error, not everything! Also, whitespaces.
This commit is contained in:
parent
cafae16072
commit
3775a9d95d
|
@ -150,7 +150,7 @@ available through the following exceptions:
|
||||||
|
|
||||||
>>> try:
|
>>> try:
|
||||||
... cur.execute("SELECT * FROM barf")
|
... cur.execute("SELECT * FROM barf")
|
||||||
... except Exception, e:
|
... except psycopg2.Error as e:
|
||||||
... pass
|
... pass
|
||||||
|
|
||||||
>>> e.pgcode
|
>>> e.pgcode
|
||||||
|
@ -159,6 +159,7 @@ available through the following exceptions:
|
||||||
ERROR: relation "barf" does not exist
|
ERROR: relation "barf" does not exist
|
||||||
LINE 1: SELECT * FROM barf
|
LINE 1: SELECT * FROM barf
|
||||||
^
|
^
|
||||||
|
|
||||||
.. attribute:: cursor
|
.. attribute:: cursor
|
||||||
|
|
||||||
The cursor the exception was raised from; `None` if not applicable.
|
The cursor the exception was raised from; `None` if not applicable.
|
||||||
|
@ -170,7 +171,7 @@ available through the following exceptions:
|
||||||
|
|
||||||
>>> try:
|
>>> try:
|
||||||
... cur.execute("SELECT * FROM barf")
|
... cur.execute("SELECT * FROM barf")
|
||||||
... except Exception, e:
|
... except psycopg2.Error, e:
|
||||||
... pass
|
... pass
|
||||||
|
|
||||||
>>> e.diag.severity
|
>>> e.diag.severity
|
||||||
|
|
Loading…
Reference in New Issue
Block a user