Global error handling

by ffMathy

HTML

<script>
	//we set up a global error handler.
  var oldOnError = window.onerror;
  window.onerror = function(errorMsg, url, lineNumber, column, errorObj) {
  	if(oldOnError) oldOnError(errorMsg, url, lineNumber, column, errorObj);
    alert(url);
  };
</script>

<script>
	//here is a script that throws an error
  throw 'foo';
</script>

<script>
	
</script>

<script>
	//here is a dandomain script that throws an error
  throw 'dandomain foo';
</script>