Throw exception out of a function : Exception : Development JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Development » Exception »

 

Throw exception out of a function

















<html>
<head>
<title>Try Catch Example</title>
<script type="text/javascript">

function addTwoNumbers(a, b) {
    throw new Error("Two numbers are required.");
}

try {
    result = addTwoNumbers(90);
catch (oException) {
    alert(oException.message);
}

</script>
</head>
<body>
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Development
» Exception