Skip to content

Commit

Permalink
Add APIError catch
Browse files Browse the repository at this point in the history
  • Loading branch information
judtinzhang committed Sep 10, 2023
1 parent 660fdf8 commit 5524422
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 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 DiningAPIWrapper, APIError
from dining.models import DiningMenu, Venue
from dining.serializers import DiningMenuSerializer

Expand All @@ -23,8 +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)

class Menus(generics.ListAPIView):
"""
Expand Down

0 comments on commit 5524422

Please sign in to comment.