Try catch user exception : Error « Development « JavaScript Tutorial






<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>








4.6.Error
4.6.1.Try catch user exception
4.6.2.Use Error
4.6.3.Throw out an Error
4.6.4.Catch an error (IE)