def check_status_code(self, status_code): if status_code == 400: raise GeocoderResultError( "Bad request (Server returned status 400)") elif status_code == 500: raise GeocoderResultError( "Unkown error (Server returned status 500)") elif status_code == 601: raise GQueryError("An empty lookup was performed") elif status_code == 602: raise GQueryError( "No corresponding geographic location could be found for the specified location, possibly because the address is relatively new, or because it may be incorrect." ) elif status_code == 603: raise GQueryError( "The geocode for the given location could be returned due to legal or contractual reasons" ) elif status_code == 610: raise GBadKeyError( "The api_key is either invalid or does not match the domain for which it was given." ) elif status_code == 620: raise GTooManyQueriesError( "The given key has gone over the requests limit in the 24 hour period or has submitted too many requests in too short a period of time." )
def check_status(status): '''Validates error statuses.''' if status == 'ZERO_RESULTS': raise GQueryError( 'The geocode was successful but returned no results. This may' ' occur if the geocode was passed a non-existent address or a' ' latlng in a remote location.') elif status == 'OVER_QUERY_LIMIT': raise GTooManyQueriesError( 'The given key has gone over the requests limit in the 24' ' hour period or has submitted too many requests in too' ' short a period of time.') elif status == 'REQUEST_DENIED': raise GQueryError( 'Your request was denied, probably because of lack of a' ' sensor parameter.') elif status == 'INVALID_REQUEST': raise GQueryError('Probably missing address or latlng.') else: raise GeocoderResultError('Unkown error.')