Bug 644 86/7386/1
authorlombardofr <lombardo@everyup.it>
Thu, 4 Apr 2019 15:29:20 +0000 (17:29 +0200)
committerlombardofr <lombardo@everyup.it>
Thu, 4 Apr 2019 15:29:20 +0000 (17:29 +0200)
Change-Id: I490398cebf9d0fcfbd506ed33913a017e7d55d4f
Signed-off-by: lombardofr <lombardo@everyup.it>
authosm/backend.py
authosm/exceptions.py
projecthandler/middleware.py

index 628eb6a..b8342eb 100644 (file)
@@ -61,3 +61,4 @@ class OsmBackend(object):
             return OsmUser.objects.get(pk=user_id)
         except OsmUser.DoesNotExist:
             return None
+
index c0b061d..e29f204 100644 (file)
@@ -16,4 +16,5 @@
 
 
 class OSMAuthException(Exception):
+    
     pass
index 89ae94d..2389ff3 100644 (file)
@@ -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