Skip to content

Comment on The State of Client side JavaScript Error Reportingparent

Comments

The advantage to the try() method is you get stack traces for browsers other than Chrome. With Chrome you can get the stack trace easily. just do:

    window.onerror = function(msg,url,line,col,err) { 
      console.log(err.stack) 
    }
If that doesn't work for you, you can get it like:
    window.onerror = function() {
      console.log(window.event.error.stack)
    }

I wouldn't want litter my code with Airbrake.try(); onerror is good enough since you get stack traces from Chrome. When there is a pesky error, I tend to do something like:
    throw JSON.stringify(some_var_to_watch);
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.