AnsweredAssumed Answered

Javascript window.onerror

Question asked by cleotokos on Jun 26, 2015
Latest reply on Jun 26, 2015 by cleotokos

I'm trying to have an alert popup whenever javascript logs an error. Am I correct in using the code:


window.onerror = function (errorMsg, url, lineNumber) {
    alert('Error: ' + errorMsg + ' Script: ' + url + ' Line: ' + lineNumber);


This seems not to produce an alert box. Currently my map is creating a 401 error for a layer every time it loads, as well as an error for a missing favicon, so something should be popping up in the alert box. I've tried putting this code at the start of my javascript file before any other code, inside a function to update layers when they are turned on and off, and inside a function that runs on map load...nothing happens. I'm still learning my way around Javascript so not sure where I'm going wrong.