JavaScript – Advanced Learning

Error Handling in JavaScript

web designing institutes, web development institutes in gurgoan, web designing courses, web development courses, top web designing institutes in gurgaon,

Exception is the major part of object-oriented programming as well as in JavaScript in details.

The try statement lets you test a block of code for errors. you may put those statements where exceptions or errors may occured.

The catch statement lets you handle the error.

The throw statement used to raise your own exception or custom errors.

The finally statement will execute whether an exception or error raise or not.

Example:

<html>

<head>

<script>

function test()

{

try

{

alerta(“Test”);

}

catch(err)

{

alert(“invalid keyword ” +err);

}

}

</script>

</head>

<body>

<input type=”button” value=”Run” onclick=”test()”>

</body>

</html>

javascript tutorial, Basic Javasript, Javascript course, javascript

Errors- Additional Details

<script type=”text/javascript”>

<!– three  variables msg, url and line here   –>

window.onerror = function (msg, url, line)

{

alert(msg);

alert(“Dcoument Name: ” + url + “At Line Number ” + line );

}

 

</script>

</head>

<body>

<input type=”button” value=”Test Error” onclick=”test()” />

</body>

</html>

author image

About admin

You Might Also Like...

SEO – Search Engine Optimization
Hirdesh Bhardwaj

2 Comments

  1. Cheap

    Nice to see this article looking forward to seeing more thanks.

  2. Nidika Offer Call Girls in Bangalore

    Nice to see this article looking forward to seeing more thanks.

Comments are closed.

Enjoy the tutorial? Please spread the word :)

Follow by Email
Facebook
Facebook
YouTube94
YouTube