google-maps-services-java: Geocoding: API throws OverQueryLimitException instead of OverDailyLimitException
Environment details
- Geocoding API
- JDK: OpenJdk 1.8.0_212
- Library Version: 0.15.0
Steps to reproduce
- Set a daily limit of 1 in the api
- Execute more than one geocoding Command
- Check the class of the thrown exception
Should
A OverDailyLimitException
is thrown
Is
A OverQueryLimitException
is thrown
Code example
try {
geocodingApi.geocode(geoApiContext, address).await();
} catch (ApiException e) {
if (e instanceof OverDailyLimitException) {
LOG.warn("The daily query limit has been reached for the apiKey {}", geocodingModule.getApiKey());
} else if (e instanceof OverQueryLimitException) {
LOG.warn("A rate limit has been reached for the apiKey {}, please try again in 1 minute", geocodingModule.getApiKey());
} else {
LOG.error("An API exception occurred while trying to geocode {} with the apiKey {}", address, apiKey, e);
}
}
...
Bug
The api currently returns
You have exceeded your daily request quota for this API. If you did not set a custom daily request quota, verify your project has an active billing account: http://g.co/dev/maps-no-account
instead of
You have exceeded your daily request quota for this API.
as expected and checked for in the ApiException class.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (16 by maintainers)
Commits related to this issue
- fix: googlemaps#697 Changed expected error message in to ApiException — committed to abdul4samad/google-maps-services-java by abdul4samad 3 years ago
- fix: googlemaps#697 Changed expected error message in to ApiException (#708) * fix: googlemaps#697 Changed expected error message in to ApiException * Update src/main/java/com/google/maps/errors/A... — committed to googlemaps/google-maps-services-java by abdul4samad 3 years ago
- chore(release): 0.15.3 [skip ci] ## [0.15.3](https://github.com/googlemaps/google-maps-services-java/compare/v0.15.2...v0.15.3) (2021-01-05) ### Bug Fixes * googlemaps[#697](https://github.com/goog... — committed to googlemaps/google-maps-services-java by semantic-release-bot 3 years ago
- fix: googlemaps#675 Changed return logic of DirectionsApi (#709) * fix: googlemaps#697 Changed expected error message in to ApiException * Update src/main/java/com/google/maps/errors/ApiException.... — committed to googlemaps/google-maps-services-java by abdul4samad 3 years ago
- chore(release): 0.15.4 [skip ci] ## [0.15.4](https://github.com/googlemaps/google-maps-services-java/compare/v0.15.3...v0.15.4) (2021-01-19) ### Bug Fixes * googlemaps[#675](https://github.com/goog... — committed to googlemaps/google-maps-services-java by semantic-release-bot 3 years ago
- fix : googlemaps#697 missing URL check for ApiException line number 52 . missing URL in the check inside ApiException.java — committed to PratikBorhade302/google-maps-services-java by PratikBorhade302 3 years ago
@PratikBorhade302 how is it going? Can I help you out somehow?
@PratikBorhade302 as soon as you limited the daily-quote, you should be able to reproduce the bug by executing at least 2 call to the api (e.g. executing this line twice:
geocodingApi.geocode(geoApiContext, address).await();
). This should throw the OverDailyLimitException which you are trying to reproduce.@PratikBorhade302 Sure, go ahead an use it. The daily limit can be set at this page of your project: https://console.cloud.google.com/google/maps-apis/quotas after selecting the project and the Geocoding API you have three accordeons, at the bottem of the third (Requests) you should see the limits and be able to edit them.
Apologies for chiming in just now. I’ve had limited bandwidth and have not had the chance to look into this issue.
@PratikBorhade302, the best way to test your change would be to add a new test (e.g.
ApiExceptionTest.java
) within this package https://github.com/googlemaps/google-maps-services-java/tree/master/src/test/java/com/google/maps and validate that the correct exception is raised. If you send a pull request with the changes, I’ll review it. I appreciate the help.