bb1769

JSAPI capturing errors in application and making debugging difficult

Discussion created by bb1769 on Aug 26, 2013
Latest reply on Sep 25, 2013 by JUihlein-esristaff
In recent versions of the JavaScript API (at least the compact version, here v. 3.6), the minified JSAPI is catching/capturing errors within my own JavaScript code. The result is that I see errors in the browser error console, but I cannot track down where the error is coming from. For example, today I saw an error in the console (here Google Chrome's console) of "TypeError", with a message of "undefined is not a function". That's it - no further error information or stack trace.

The console points to a location in the JSAPI. I used Chrome's "pretty print" function ("{}" at the bottom of the console) to try to track down the error source, by adding a break point at the line identified (in this case, line 1869). But when I trip the offending code and hit the break point, the Call Stack only points to lines internal to the JSAPI.

I eventually tracked down my error, which had nothing to do with the JSAPI itself - it was just that I had used 'this' assuming it referenced my custom object when it actually pointed to the window object. I see no reason that the JSAPI should be catching this kind of error.

Is there any way to prevent the JSAPI from catching all errors in code outside the JSAPI itself? I'm sure I could add try/catch JavaScript blocks, but that's impractical to do in every single function or code block during development.

BY THE WAY, I DO NOT WORK FOR ESRI. I did up until 2009, but the Forum website administrator has ignored my repeated requests to remove the ESRI logo from my posts.

Outcomes