def web_sight_exception_handler(exc, context):
"""
This is a custom Django exception handler that handles all exceptions thrown by the Web Sight REST
API.
:param exc: The exception that was thrown.
:param context: The context in which the exception was thrown.
:return: A response to return to the requesting user.
"""
if isinstance(exc, IntegrityError):
return handle_integrity_error(exc, context)
elif isinstance(exc, ValidationError):
return handle_validation_error(exc, context)
elif isinstance(exc, WsRestNonFieldException):
return handle_non_field_error(exc, context)
elif isinstance(exc, APIException):
return handle_api_exception(exc, context)
else:
return None
评论列表
文章目录