From: lombardofr Date: Thu, 4 Apr 2019 15:29:20 +0000 (+0200) Subject: Bug 644 X-Git-Tag: v6.0.0~13 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F7386%2F1;p=osm%2FLW-UI.git Bug 644 Change-Id: I490398cebf9d0fcfbd506ed33913a017e7d55d4f Signed-off-by: lombardofr --- diff --git a/authosm/backend.py b/authosm/backend.py index 628eb6a..b8342eb 100644 --- a/authosm/backend.py +++ b/authosm/backend.py @@ -61,3 +61,4 @@ class OsmBackend(object): return OsmUser.objects.get(pk=user_id) except OsmUser.DoesNotExist: return None + diff --git a/authosm/exceptions.py b/authosm/exceptions.py index c0b061d..e29f204 100644 --- a/authosm/exceptions.py +++ b/authosm/exceptions.py @@ -16,4 +16,5 @@ class OSMAuthException(Exception): + pass diff --git a/projecthandler/middleware.py b/projecthandler/middleware.py index 89ae94d..2389ff3 100644 --- a/projecthandler/middleware.py +++ b/projecthandler/middleware.py @@ -1,4 +1,16 @@ +from authosm.exceptions import OSMAuthException +from django.shortcuts import render +import json class OsmProjectMiddleware(object): def process_view(self, request, view_func, view_args, view_kwargs): - return None \ No newline at end of file + return None + + def process_exception(self, request, exception): + if isinstance(exception, OSMAuthException): + try: + error_message = exception.message['detail'] + except Exception as e: + print e + error_message = 'Unknown error' + return render(request, 'error.html', {'error_message': error_message, 'collapsed_sidebar': False}) \ No newline at end of file