Mega Code Archive

 
Categories / JavaScript Tutorial / Statement
 

Exception handling with trycatch

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