Skip to content

Commit

Permalink
Fixing error with some HERE responses
Browse files Browse the repository at this point in the history
  • Loading branch information
arnasbr committed Sep 30, 2024
1 parent 6c64c07 commit f8b4fa7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/traveltime_google_comparison/requests/here_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ async def send_request(
for section in first_route["sections"]
)

# For some reason, HERE provider returns 0 duration, 0 length
# for some routes in the mountains, but doesn't indicate anywhere
# that it failed. Returning 0 fails `asType(int)` conversion later.
# Example route in UK where this happens:
# "58.61966879999991, -5.0040819999999995","58.578906999999894, -4.880025099999999"
if total_duration == 0:
return RequestResult(None)

return RequestResult(travel_time=total_duration)
else:
error_message = data.get("detailedError", "")
Expand Down

0 comments on commit f8b4fa7

Please sign in to comment.