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

Add APIError catch to Dining #198

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Changes from all commits
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
7 changes: 5 additions & 2 deletions backend/dining/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from dining.api_wrapper import DiningAPIWrapper
from dining.api_wrapper import APIError, DiningAPIWrapper
from dining.models import DiningMenu, Venue
from dining.serializers import DiningMenuSerializer

Expand All @@ -23,7 +23,10 @@ class Venues(APIView):
"""

def get(self, request):
return Response(d.get_venues())
try:
return Response(d.get_venues())
except APIError as e:
return Response({"error": str(e)}, status=400)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this something we have to do for a lot of views?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, you're right this seems like some behavior we would like to create a wrapper for. @vcai122 can you log this as a github issue? we can tackle it another time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


class Menus(generics.ListAPIView):
Expand Down
Loading