I’m using the python module googlemaps 1.0.2 and I cannot use a try statement in the instance that the user inputs an unknown address.
The error message that I get looks like this:
GoogleMapsError: Error 602: G_GEO_UNKNOWN_ADDRESS
My method looks like this, (without my API key):
from googlemaps import GoogleMaps
def get_distance(address, destination):
try:
gmaps = GoogleMaps(api_key)
directions = gmaps.directions(address,destination)
distance = directions['Directions']['Distance']['meters']/1600.0
return distance
except ???:
I have tried:
except GoogleMapsError:
except 'GoogleMapsError: Error 602: G_GEO_UNKNOWN_ADDRESS'
thanks
You probably haven’t imported the googlemaps.GoogleMapsError exception.