Try catch user exception : Error « Development « JavaScript Tutorial
- JavaScript Tutorial
- Development
- Error
<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>