Skip to content

Google API distance based source selection lacks informative exceptions/logs #3421

@SamJUK

Description

@SamJUK

Currently, the exceptions throw by the Google API DistanceProviders do not provide much information on the actual errors encountered.

For example:
When using an Google API key with invalid referer permissions, the API response is the following JSON

{
   "error_message" : "API keys with referer restrictions cannot be used with this API.",
   "results" : [],
   "status" : "REQUEST_DENIED"
}

Where as the exception only states "Unable to geocode address" without providing any reference to the upstream error_message.

if ($res['status'] !== 'OK') {
throw new LocalizedException(__('Unable to geocode address %1', $this->addressToString->execute($address)));
}

Either logging the response error_message and status independently or adjusting the exceptions to provide more context would simplify debugging connection issues.

This likely also affects other classes that also fetch data from the Google API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions