1

I'm wondering if its possible to run a function when a specific error is returned in the console. For example Google maps sometimes returns this error.

InvalidValueError: setPosition: not a LatLng or LatLngLiteral: in property lng: not a number

What I want to do is send an alert() message when this specific error occurs. Is this possible and how would I achieve it?

  • nice question im also interessted in, if there is a handler which will be triggered by a displayed error in the console.... –  Nov 26 '15 at 22:41
  • It's better to check the values prior to drawing the map, then you won't receive the error, otherwise, go with a try / catch block – WhiteHat Nov 26 '15 at 22:45
  • 1
    Possible duplicate of [Javascript global error handling](http://stackoverflow.com/questions/951791/javascript-global-error-handling) – Jaromanda X Nov 26 '15 at 22:47
  • @JaromandaX I am with you. –  Nov 26 '15 at 23:15

1 Answers1

1

you can use a try-catch block. see below on this page: handling a specific error

in your case:

if (e instanceof InvalidValueError) {
...
Chris
  • 221
  • 1
  • 8