On Tuesday, July 10, 2012 7:45:58 AM UTC-6, Dan Gentry wrote:
>
> 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
> and 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?
>
There's nothing specific to Oracle about this. First, make sure you've
read:
https://docs.djangoproject.com/en/1.4/howto/error-reporting/
In your case you might do any of the following:
1) Customize the 500.html server error template to provide a more
user-friendly message.
2) Customize the server error view, which by default just renders the
500.html template:
https://docs.djangoproject.com/en/1.4/topics/http/views/#the-500-server-error-view
3) Use a middleware to customize completely how otherwise unhandled errors
are processed. You can create a customized 500 (or 503) response and do
whatever admin notification and other processing you want.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/r5lfeWa1iAgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.