def handle_validation_error(exc, context):
"""
Handle the given ValidationError and return a response.
:param exc: The exception that was thrown.
:param context: The context in which the exception was thrown.
:return: A Django Response object.
"""
response = exception_handler(exc, context)
response.status_code = 400
response.data = {
"status_code": 400,
"message": "Invalid input received.",
"detail": "There was an error with the data that you submitted. Please check your input and try again.",
"error_fields": exc.get_full_details(),
}
return response
评论列表
文章目录