mirror of
https://github.com/Dadechin/Dashboard-XRoom.git
synced 2025-07-03 00:34:34 +00:00
16 lines
423 B
Python
16 lines
423 B
Python
# in your_project/utils.py or a similar file
|
|
|
|
from rest_framework.views import exception_handler
|
|
|
|
def custom_exception_handler(exc, context):
|
|
response = exception_handler(exc, context)
|
|
|
|
if response is not None:
|
|
response.data = {
|
|
"status": response.status_code,
|
|
"data": {},
|
|
"message": str(exc.detail) if hasattr(exc, 'detail') else str(exc)
|
|
}
|
|
|
|
return response
|