views:

49

answers:

1

I am currently working on a site that includes javascript code that we get from several different sources and need to run on the site I maintain. Every once and a while some of this code breaks without our knowing until its too late. Is there a monitoring tool that will crawl our site and look for javascript errors and report them or could this be incorporated into a selenium test somehow?

A: 

On the sites I develop, I wrap everything in try ... catch blocks, and if the exceptions I catch cannot be handled, I always generate an AJAX request to a script which emails an error report to the development team with as much information as I can gather.

If the code is code you didn't write yourself and try...catch blocks would be difficult to add, you can use the window.onerror handler instead:

<script type="text/javascript">
window.onerror = function()
{
  // Your code to generate an AJAX request to your error report script here
}
</script>
Josh