Re: [cx-oracle-users] best way to get oracle error number from exception?
Brought to you by:
atuining
From: Anthony T. <ant...@gm...> - 2005-10-24 22:26:58
|
No particularly good reason -- it just happens to be a way of indicating that there should be one and only one entry in the list. An exception is raised if there is not whereas args[0] does not raise the exception. Its an open question which is the better code. Any further comments? On 10/24/05, Guido van Rossum <gu...@el...> wrote: > > try: > > cursor.execute("select 1 / 0 from dual") > > except cx_Oracle.DatabaseError, e: > > print "Exception:", e # this is what you are looking at > > right now > > errorObj, =3D e.args # this is the actual "error" > > This is overly subtle. Why not write > > errorObj =3D e.args[0] > > ? I can't think of a situation where that wouldn't work and the former > would. > > > that cx_Oracle raises > > print "ErrorCode:", errorObj.code > > print "ErrorMessage:", errorObj.message > > --Guido van Rossum > > > ------------------------------------------------------- > This SF.Net email is sponsored by the JBoss Inc. > Get Certified Today * Register for a JBoss Training Course > Free Certification Exam for All Training Attendees Through End of 2005 > Visit http://www.jboss.com/services/certification for more information > _______________________________________________ > cx-oracle-users mailing list > cx-...@li... > https://lists.sourceforge.net/lists/listinfo/cx-oracle-users > |