File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed <
8000
th scope="col">Original file line numberDiff line number Diff line change 3
3
"""
4
4
from __future__ import unicode_literals
5
5
6
+ import sys
7
+
8
+ from django .conf import settings
6
9
from django .core .exceptions import PermissionDenied
7
10
from django .db import models
8
11
from django .http import Http404
9
- from django .http .response import HttpResponseBase
12
+ from django .http .response import HttpResponse , HttpResponseBase
10
13
from django .utils import six
11
14
from django .utils .encoding import smart_text
12
15
from django .utils .translation import ugettext_lazy as _
16
+ from django .views import debug
13
17
from django .views .decorators .csrf import csrf_exempt
14
18
from django .views .generic import View
15
19
@@ -91,7 +95,11 @@ def exception_handler(exc, context):
91
95
set_rollback ()
92
96
return Response (data , status = status .HTTP_403_FORBIDDEN )
93
97
94
- # Note: Unhandled exceptions will raise a 500 error.
98
+ # throw django's error page if debug is True
99
+ if settings .DEBUG :
100
+ exception_reporter = debug .ExceptionReporter (context .get ('request' ), * sys .exc_info ())
101
+ return HttpResponse (exception_reporter .get_traceback_html (), status = 500 )
102
+
95
103
return None
96
104
97
105
You can’t perform that action at this time.
0 commit comments