mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-28 17:29:36 +02:00
Merge branch 'development' of github.com:seanmorley15/AdventureLog into development
This commit is contained in:
commit
03c76adc6d
2 changed files with 11 additions and 6 deletions
|
@ -84,12 +84,17 @@ def reverse_geocode(lat, lon, user):
|
||||||
return extractIsoCode(user, data)
|
return extractIsoCode(user, data)
|
||||||
|
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
return {"error": "Could not connect to geocoding service"}
|
log_error(f"ConnectionError in reverse_geocode: {e}")
|
||||||
|
return {"error": "An internal error occurred while processing the request"}
|
||||||
except requests.exceptions.Timeout as e:
|
except requests.exceptions.Timeout as e:
|
||||||
return {"error": "Geocoding service timed out"}
|
log_error(f"Timeout in reverse_geocode: {e}")
|
||||||
|
return {"error": "An internal error occurred while processing the request"}
|
||||||
except requests.exceptions.HTTPError as e:
|
except requests.exceptions.HTTPError as e:
|
||||||
return {"error": f"HTTP error from geocoding service: {e}"}
|
log_error(f"HTTPError in reverse_geocode: {e}")
|
||||||
|
return {"error": "An internal error occurred while processing the request"}
|
||||||
except requests.exceptions.JSONDecodeError as e:
|
except requests.exceptions.JSONDecodeError as e:
|
||||||
return {"error": "Invalid response from geocoding service"}
|
log_error(f"JSONDecodeError in reverse_geocode: {e}")
|
||||||
|
return {"error": "An internal error occurred while processing the request"}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"error": f"Unexpected geocoding error: {str(e)}"}
|
log_error(f"Unexpected error in reverse_geocode: {e}")
|
||||||
|
return {"error": "An internal error occurred while processing the request"}
|
|
@ -25,7 +25,7 @@ class ReverseGeocodeViewSet(viewsets.ViewSet):
|
||||||
return Response({"error": "Invalid latitude or longitude"}, status=400)
|
return Response({"error": "Invalid latitude or longitude"}, status=400)
|
||||||
data = reverse_geocode(lat, lon, self.request.user)
|
data = reverse_geocode(lat, lon, self.request.user)
|
||||||
if 'error' in data:
|
if 'error' in data:
|
||||||
return Response(data, status=400)
|
return Response({"error": "An internal error occurred while processing the request"}, status=400)
|
||||||
return Response(data)
|
return Response(data)
|
||||||
|
|
||||||
@action(detail=False, methods=['post'])
|
@action(detail=False, methods=['post'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue