mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 10:26:16 +00:00
Error response
This commit is contained in:
@ -204,7 +204,7 @@ def custom_error_response(detail, response_status):
|
|||||||
if not detail:
|
if not detail:
|
||||||
"""when details is empty"""
|
"""when details is empty"""
|
||||||
detail = {}
|
detail = {}
|
||||||
return Response({"error": detail, "status": "failed", "code": response_status})
|
return Response({"error": detail, "status": "failed", "code": response_status}, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
|
||||||
def get_user_data(attrs):
|
def get_user_data(attrs):
|
||||||
|
@ -337,7 +337,7 @@ class ApproveTaskAPIView(viewsets.ModelViewSet):
|
|||||||
serializer.save()
|
serializer.save()
|
||||||
return custom_response(SUCCESS_CODE['3026'], response_status=status.HTTP_200_OK)
|
return custom_response(SUCCESS_CODE['3026'], response_status=status.HTTP_200_OK)
|
||||||
else:
|
else:
|
||||||
return custom_response(ERROR_CODE['2038'], response_status=status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(ERROR_CODE['2038'], response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user