Exception handling with try/catch
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
function getMonthName (monthNumber) {
throw "InvalidMonthNumber"
}
try {
alert(getMonthName(13))
}
catch (exception) {
alert("An " + exception + " exception was encountered. Please contact the program vendor.")
}
</SCRIPT>
<BODY>
</BODY>
</HTML>
Related examples in the same category