You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What kind of database errors are ProgrammingError? If you raise a user-defined exception through the procedure raise_application_error, the cx_Oracle raising an DatabaseError.
I think is more clear use ProgrammingError for user-defined exceptions instead of DatabaseError.
withconnection.cursor() ascursor:
try:
cursor.execute("begin raise_application_error(-20000, 'Sometime strange thins just happens'); end;")
exceptcx_Oracle.ProgrammingErrorase:
print("Yes, you are busines validation error")
exceptcx_Oracle.DatabaseErrorase:
print("Hey i'm not a business validation")
Python Version: 3.7.4
cx_Oracle Version: 7.2.2
oracleinstantclient Version: 12.2
Oracle server Version : 11g XE
SO: Fedora 30
ProgrammingError is only raised for errors like "positional and named binds cannot be intermixed". Almost all Oracle errors are raised as DatabaseError. There are some that are raised as IntegrityError and OperationalError. You can take a look at the source for the function cxoError_raiseFromInfo() for the details.
As for whether ORA-20000 should be defined as a ProgrammingError instead of DatabaseError, that's a matter for debate! I'm sure others might disagree with your evaluation and I'm not sure I'm convinced either. I'll ask @cjbj to give his opinion as well.
I don't think ProgrammingError makes sense for application runtime errors. ApplicationError might be nice, but is the backward compatibility break worth it?
Activity
[-]Application error are not instance of ProgrammingError[/-][+]User-defined exceptions as ProgrammingError[/+]alexolirib commentedon Sep 20, 2019
+1
anthony-tuininga commentedon Sep 24, 2019
ProgrammingErroris only raised for errors like "positional and named binds cannot be intermixed". Almost all Oracle errors are raised asDatabaseError. There are some that are raised asIntegrityErrorandOperationalError. You can take a look at the source for the functioncxoError_raiseFromInfo()for the details.As for whether ORA-20000 should be defined as a
ProgrammingErrorinstead ofDatabaseError, that's a matter for debate! I'm sure others might disagree with your evaluation and I'm not sure I'm convinced either. I'll ask @cjbj to give his opinion as well.rafaelreuber commentedon Sep 24, 2019
Another option would be to define a new exception named ApplicationError do deal with user-defined errors.
cjbj commentedon Sep 24, 2019
I don't think ProgrammingError makes sense for application runtime errors. ApplicationError might be nice, but is the backward compatibility break worth it?
rafaelreuber commentedon Sep 26, 2019
If ApplicationError is subclass of DatabaseError, this will not break the backward compatibility.
anthony-tuininga commentedon Feb 10, 2020
True enough. If @cjbj has no objections I'll add it to cx_Oracle 8. It will cover the error numbers from -20000 to -20999.
ancc commentedon May 17, 2022
8.3 doesn't have ApplicationError. Plan is valid to add it?
cjbj commentedon May 17, 2022
I don't see it in the next major version, so we'll have to revisit when we get a moment.