Django graceful database errors

2017-06-07 Thread Damian Myerscough
Hello, I have setup a Django project that is being served via Nginx + gunicorn, however, I would like to handle graceful database failures. For example, if the ORM cannot query the database I would like to return a custom error message. ==> gunicorn.log <== [2017-06-07 06:06:01 +] [13] [DE

Re: Django graceful database errors

2017-06-07 Thread Melvyn Sopacua
On Wednesday 07 June 2017 00:15:29 Damian Myerscough wrote: > For example, if the ORM cannot query the database I would like to > return a custom error message. > > > ==> gunicorn.log <== > [2017-06-07 06:06:01 +] [13] [DEBUG] GET /incidents/ > [2017-06-07 06:06:11 +] [8] [CRITICAL] WORK

Re: Django graceful database errors

2017-06-07 Thread Damian Myerscough
When trying this using the Django test web server I am still unable to catch this error. When try the same query using a shell I can catch the exception. --- Environment: Request Method: GET Request URL: http://127.0.0.1:8000/accounts/register/ Django Version: 1.11 Python Version: 3.6.0 Insta

Re: Django graceful database errors

2017-06-07 Thread Melvyn Sopacua
On Wednesday 07 June 2017 16:19:46 Damian Myerscough wrote: > When trying this using the Django test web server I am still unable to > catch this error. When try the same query > using a shell I can catch the exception. > The above exception ((2003, "Can't connect to MySQL server on > '127.0.0.1'

Re: Django graceful database errors

2017-06-07 Thread Antonis Christofides
Hi, not answering exactly what you asked, by my 2 cents anyway: Why do you want to do this? Why does the user care whether the error was in the database or a bug in your program or a filesystem error or a network error or Redis being down or whatever? Neither is this information useful nor is it

Re: Django graceful database errors

2017-06-08 Thread Melvyn Sopacua
On Thursday 08 June 2017 09:09:32 Antonis Christofides wrote: > not answering exactly what you asked, by my 2 cents anyway: > > Why do you want to do this? Erm, that's actually good practice. This error isn't permanent and can resolve itself, so you can inform the user to try again in 5 minute