2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-16 17:56:30 +00:00

Start of exception handler

This commit is contained in:
Oliver Walters
2017-04-16 00:58:40 +10:00
parent a139a00843
commit 2e133b7744
4 changed files with 41 additions and 2 deletions

View File

@@ -79,6 +79,10 @@ TEMPLATES = [
},
]
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'InvenTree.utils.api_exception_handler'
}
WSGI_APPLICATION = 'InvenTree.wsgi.application'

View File

@@ -0,0 +1,17 @@
from rest_framework.views import exception_handler
#class APIValidationError()
def api_exception_handler(exc, context):
response = exception_handler(exc, context)
#print(response)
# Now add the HTTP status code to the response.
if response is not None:
data = {'error': response.data}
response.data = data
return response