Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mrshu
Copy link

@mrshu mrshu commented Mar 4, 2020

Hello everyone,

First of all, thanks a ton for putting geopy together!

While playing with the geocoder module and setting up GoogleV3 API, I ran into a few issues. The contents of error_message has helped me to debug it much faster and so I believe it would be good to make it part of the exception that it being raised.

I am not sure if I followed the standards of the geopy codebase, so please feel free to point that out and I'd be happy to refactor the PR to reflect it better.

Thanks!


  • GoogleV3 API response contains an error_message field when status is
    not OK. This field contains various complementary information that
    helps to debug the issue with the provided geocoder query.

    https://developers.google.com/maps/documentation/geocoding/intro#ErrorMessages

  • This commit adds the content of the error_message field to the
    GeocoderQueryError exception in cases when error_message is provided
    in the API response and the exception is to be raised.

Signed-off-by: mr.Shu [email protected]

* GoogleV3 API response contains an `error_message` field when `status` is
  not `OK`. This field contains various complementary information that
  helps to debug the issue with the provided geocoder query.

  https://developers.google.com/maps/documentation/geocoding/intro#ErrorMessages

* This commit adds the content of the `error_message` field to the
  GeocoderQueryError exception in cases when `error_message` is provided
  in the API response and the exception is to be raised.

Signed-off-by: mr.Shu <[email protected]>
@mrshu mrshu force-pushed the mrshu/googlev3-error-message branch from d9b268a to 2faaf6b Compare March 4, 2020 21:22
@mrshu
Copy link
Author

mrshu commented Mar 4, 2020

cc @KostyaEsmukov @jbouvier

@KostyaEsmukov KostyaEsmukov added this to the 1.22 milestone Mar 9, 2020
@mrshu
Copy link
Author

mrshu commented Mar 11, 2020

@KostyaEsmukov @jbouvier This is just a friendly reminder that I'd be happy to address any comments you guys may have.

Thanks!

Copy link
Member

@KostyaEsmukov KostyaEsmukov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The contents of error_message has helped me to debug it much faster and so I believe it would be good to make it part of the exception that it being raised.

The error responses are already fed to the logger:

logger.info('Received an HTTP error (%s): %s', code, body,
exc_info=False)

But I guess you didn't have them, because Google geocoder seems to respond with 200 status for errors instead of 4xx.

What bothers me with this solution is that the parts (the one from geopy and the other from API) of the resulting concatenated error messages would probably duplicate each other or even contradict to each other, causing confusion.

So I'd prefer to solve this problem other way:

  1. Either add logging of raw response bodies for errors in _check_status, like in the link above
  2. Or remove geopy's error messages and always passthrough the error message from API, like here:
    raise GeocoderServiceError(str(response['error']))
    But in this option we need to be sure that the error messages from API are not less informative than the ones we have now.

@KostyaEsmukov KostyaEsmukov removed this from the 1.22 milestone May 9, 2020
@KostyaEsmukov KostyaEsmukov added this to the 2.3 milestone Mar 21, 2021
@KostyaEsmukov
Copy link
Member

e1c00c4 should fix the issue: the API's error_message will now be passed to the exception messages when it's present (which, I suppose, should almost always be true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants