Call onError with the full Error object
ayamflow opened this issue · comments
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 ?
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.
👍 All good!