[DB-SIG] DCOracle-1.3.0 try/except

LD Landis ldl@LDL.HealthPartners.COM
Thu, 3 Aug 2000 16:49:26 -0500 (CDT)


Hi,

  Dumb question... How do I do a "meaningful" try/except for DCOracle
  such that I can look at the error that was returned?  I had thought
  that something like:

   try:
     db = DCOracle.Connect("user/password@instance.world")
   except DCOracle, e:
     print "Error", e

  would work, but it doesn't...  Also tried using the various errors
  that Python catches without success... Here's what I get:

Python 1.5.2 (#1, Jul 21 2000, 14:17:35) [C] on aix4
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> importr  DCOracle
>>> db = DCOracle.Connect("user/password@bogus.world")
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/opt/oracle/local/lib/python1.5/DCOracle/ocidb.py", line 76, in __init__
    sc=oci_8.Logon(u,p,s)
OracleError: ('ORA-12154: TNS:could not resolve service name\012', 12154)
>>> try:
...   db = DCOracle.Connect("user/password@bogus.world")
... except OracleError:
...   print "error caught"
... 
Traceback (innermost last):
  File "<stdin>", line 3, in ?
AttributeError: OracleError
>>> try:
...   db = DCOracle.Connect("user/password@bogus.world")
... except DCOracle.OracleError:
...   print "error caught"
... 
Traceback (innermost last):
  File "<stdin>", line 3, in ?
AttributeError: OracleError
>>> try:
...   db  = DCOracle.Connect("user/password@bogus.world")
... except DCOracle.error:
...   print "caught"
... 
Traceback (innermost last):
  File "<stdin>", line 2, in ?
  File "/opt/oracle/local/lib/python1.5/DCOracle/ocidb.py", line 76, in __init__
    sc=oci_8.Logon(u,p,s)
OracleError: ('ORA-12154: TNS:could not resolve service name\012', 12154)
>>> try:
...   db = DCOracle.Connect("user/password@bogus.world")
... except DCOracle.error, e:
...   print "caught", e
... 
Traceback (innermost last):
  File "<stdin>", line 2, in ?
  File "/opt/oracle/local/lib/python1.5/DCOracle/ocidb.py", line 76, in __init__
    sc=oci_8.Logon(u,p,s)
OracleError: ('ORA-12154: TNS:could not resolve service name\012', 12154)
>>> print e
Traceback (innermost last):
  File "<stdin>", line 1, in ?
NameError: e
>>> try:
...   db = DCOracle.Connect("user/password@bogus.world")
... except:
...   print "Gotcha Suckers!"
... 
Gotcha Suckers!
>>> print DCOracle.error
oci.error
>>> print DCOracle.error
'oci.error'
>>> DCOracle.error
'oci.error'
>>> ^D