Re: [cx-oracle-users] Is it possible to get an error number from a cx_Oracle.Exception object?
Brought to you by:
atuining
From: Anthony T. <an...@co...> - 2004-01-21 16:19:43
|
It is possible but the method isn't much of an improvement over the code below. :-( If anyone has an idea of how to create an exception in C that makes this a little more reasonable, please let me know! except cx_Oracle.DatabaseError, e: errorObj, = e.args if errorObj.code == 904: # handle this error There are three attributes on the errorObj object: code --> the numeric error code reported by Oracle message --> the message reported by Oracle context --> internal context in which the error was raised Hope that helps. On Wed, 2004-01-21 at 09:05, Moore, Paul wrote: > I want to trap a particular Oracle error (904, invalid column name). > At the moment, I'm doing that by > > except cx_Oracle.DatabaseError, e: > if str(e).startswith("ORA-00904"): > # handle this error > > While I can't imagine that the string format of the error will ever > change enough to make this invalid, I'd prefer to check the error number > directly. But I can't see a way of getting that number. > > Am I missing it, or is this not possible? > > Thanks, > Paul. > > > ------------------------------------------------------- > The SF.Net email is sponsored by EclipseCon 2004 > Premiere Conference on Open Tools Development and Integration > See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. > http://www.eclipsecon.org/osdn > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users -- |