Wednesday, August 12, 2009

JavaScript Error Handling

JavaScript Standard Error Instance Properties
constructor
    Specifies the function that created an instance's prototype.
message
    Error message.
name
    Error name.

<html>
    <head>
        <title>Error Handling</title>
        <script language='javascript'>
        window.onload = function()
        {
            try
            {
                var x = 1;
                var value = x / y;               
            }
            catch(err)
            {
                alert("constructor"+ ": " + err.constructor +'\r\n' + 'message'+ ": " + err.message + '\r\n' + 'name' + ": "+ err.name);
            }
            finally
            {
                alert("Finally block");
            }

        }
        </script>
    </head>
</html>




No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.