Documentation and Books

Recent site activity

Web Development‎ > ‎JavaScript‎ > ‎

How to create my own JavaScript custom error handler?

The following code snipped demonstrated how you could setup your own custom error handler.

  function customHandler(desciption, page, line, position)  {
alert(
'JavaScript error occurred! \n'
+'\nError description: \t'+description
+'\nPage address: \t'+page
+'\nLine number: \t'+line
+'\nPosition: \t'+position
)

return true;
}

window.onerror = customHandler;

This will display a custom message on screen with information about the JavaScript error that occured.