Commit 1a5007e3 authored by Gert Paimla's avatar Gert Paimla
Browse files

add OperationalError clause to exceptionhandler

parent 8ef9f696
......@@ -6,6 +6,7 @@ from django.shortcuts import redirect
from django.utils.deprecation import MiddlewareMixin
from texta.settings import ERROR_LOGGER, STATIC_URL
from django.db.utils import OperationalError
class ExceptionHandlerMiddleware(MiddlewareMixin):
......@@ -16,6 +17,12 @@ class ExceptionHandlerMiddleware(MiddlewareMixin):
template_data = {'STATIC_URL': STATIC_URL, 'allowed_datasets': None, 'language_models': None}
return redirect("/", context=template_data)
if isinstance(exception, OperationalError):
logging.getLogger(ERROR_LOGGER).exception(exception)
messages.error(request, "Error, please refresh the page!".format(exception))
template_data = {'STATIC_URL': STATIC_URL, 'allowed_datasets': None, 'language_models': None}
return redirect("/", context=template_data)
else:
logging.getLogger(ERROR_LOGGER).exception(exception)
messages.error(request, "Error, please try again or contact the developers: {}!".format(exception))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment