Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Error Handling in AssetViewSet #1737

Merged
merged 4 commits into from
Jan 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions care/facility/api/viewsets/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
return Response({"result": result}, status=status.HTTP_200_OK)

except ValidationError as e:
return Response({"message": e.detail}, status=status.HTTP_400_BAD_REQUEST)
return Response({"detail": e.detail}, status=status.HTTP_400_BAD_REQUEST)

Check warning on line 341 in care/facility/api/viewsets/asset.py

View check run for this annotation

Codecov / codecov/patch

care/facility/api/viewsets/asset.py#L341

Added line #L341 was not covered by tests

except KeyError as e:
return Response(
Expand All @@ -347,7 +347,12 @@
)

except APIException as e:
return Response(e.detail, e.status_code)
return Response(

Check warning on line 350 in care/facility/api/viewsets/asset.py

View check run for this annotation

Codecov / codecov/patch

care/facility/api/viewsets/asset.py#L350

Added line #L350 was not covered by tests
{
"detail": f"Communication with the middleware failed.\nReceived status code: {e.status_code}"
},
status=status.HTTP_424_FAILED_DEPENDENCY,
Ashesh3 marked this conversation as resolved.
Show resolved Hide resolved
)

except Exception as e:
print(f"error: {e}")
Expand Down
Loading