Exception-Handling in JavaScript

The following JavaScript code demonstrates a simple exception handler.

{copytext|div1}
try
{
    // Your code goes here
}
catch (ex)
{
    alert('Error: ' + ex.name + ' - ' + ex.message);
}