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

Call onError with the full Error object #7

Closed
ayamflow opened this issue Jan 9, 2015 · 2 comments
Closed

Call onError with the full Error object #7

ayamflow opened this issue Jan 9, 2015 · 2 comments

Comments

@ayamflow
Copy link

ayamflow commented Jan 9, 2015

Hi there,

if you use the lib without IP Fallback, the error param from the onError callback is only the original error message. See this line. Wouldn't it be better to pass the whole error, so this would allow something like:

onGeolocationError: function(error) {
      switch (error.code) {
        case error.PERMISSION_DENIED:
        // ...
        case error.TIMEOUT:
        // ...
        case error.POSITION_UNAVAILABLE:
        // ...
    }

thoughts ?

@onury
Copy link
Owner

onury commented Jan 9, 2015

Hi Florian, Thanks for your input.

I think you're right. I've updated the code (v1.2.6) so that; instead of a String, all error callbacks are passed either an Error or PositionError object, (depending on the geo source used).

The passed object will always have a message property and if it's an HTML5 PositionError, you'll also get the code property and others... I've also added a helper method isPositionError().

Pls check it out and let me know if this works for you.

@ayamflow
Copy link
Author

ayamflow commented Jan 9, 2015

👍 All good!

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

2 participants