Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error handling for google geocoder #184

Open
speedazerty opened this issue Jul 28, 2016 · 3 comments
Open

Error handling for google geocoder #184

speedazerty opened this issue Jul 28, 2016 · 3 comments

Comments

@speedazerty
Copy link

speedazerty commented Jul 28, 2016

When google API sends a response with a 400 status code (or any non 200 codes), It is not possible to see the details of the error on the callback of the geocode function.

example :

geocode('', function(err, result){
  // err does not contain error details from google like error_message 'INVALID_request'
  // it is not contained into result neither
})

Test endpoint :
http://maps.googleapis.com/maps/api/geocode/json?address=

P.S. : I can send a pull request to solve it

@Shane-Neeley
Copy link

Has this been implemented? @speedazerty @nchaulet

@AlexMachin1997
Copy link

Hey,

You could try this. Seems to be working for me, you will need to modify the res.flash as thas a plugin Im using

        if (err || data.status === 'ZERO_RESULTS') {
            req.flash('error', 'Invalid address, try typing a new address');
            return res.redirect('back');
        }

        if (err || data.status === 'REQUEST_DENIED') {
            req.flash('error', 'Something Is Wrong Your Request Was Denied');
            return res.redirect('back');
        }

        if (err || data.status === 'OVER_QUERY_LIMIT') {
            req.flash('error', 'All Requests Used Up');
            return res.redirect('back');
        }

@bakasmarius
Copy link

Hi, any updates on this?

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

No branches or pull requests

5 participants