Catching Oracle Errors in Django
- by Dashdrum
My Django app runs on an Oracle database.
A few times a year, the database is unavailable because of a scheduled process or unplanned downtime. However, I can't see how to catch the error a give a useful message back to the requester. Instead, a 500 error is triggered, and I get an email (or hundreds) showing the exception. One example is:
File "/opt/UDO/env/events/lib/python2.6/site-packages/django/db/backends/oracle/base.py", line 447, in _cursor
self.connection = Database.connect(conn_string, **conn_params)
DatabaseError: ORA-01035: ORACLE only available to users with RESTRICTED SESSION privilege
I see a similar error with a different ORA number when the DB is down.
Because the exception is thrown deep within the Django libraries, and can be triggered by any of my views or the built in admin views, I don't know where any exception trapping code would go.
Any suggestions?