1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 07:19:36 +02:00

fix: improve error handling for Overpass API connection failures

This commit is contained in:
Sean Morley 2025-01-17 18:22:03 -05:00
parent e9084db832
commit 75162bbf7b

View file

@ -24,8 +24,8 @@ class OverpassViewSet(viewsets.ViewSet):
response = requests.get(url, headers=self.HEADERS)
response.raise_for_status() # Raise an exception for HTTP errors
return response.json()
except requests.exceptions.RequestException as e:
return Response({"error": str(e)}, status=500)
except requests.exceptions.RequestException:
return Response({"error": "Failed to connect to Overpass API"}, status=500)
except requests.exceptions.JSONDecodeError:
return Response({"error": "Invalid response from Overpass API"}, status=400)