Exception handling with try/catch : try catch « Statement « JavaScript Tutorial






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








3.13.try catch
3.13.1.try...catch
3.13.2.Catch that error
3.13.3.Exception handling with try/catch