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:
@@ -79,6 +79,10 @@ TEMPLATES = [
|
||||
},
|
||||
]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'EXCEPTION_HANDLER': 'InvenTree.utils.api_exception_handler'
|
||||
}
|
||||
|
||||
WSGI_APPLICATION = 'InvenTree.wsgi.application'
|
||||
|
||||
|
||||
|
17
InvenTree/InvenTree/utils.py
Normal file
17
InvenTree/InvenTree/utils.py
Normal 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
|
Reference in New Issue
Block a user