Throw out an Error : Error « Development « JavaScript Tutorial






<HTML>
<HEAD>
   <TITLE>Throw that error!</TITLE>
<SCRIPT>
function throwError(errString) {
   try {
      throw new Error (42, errString);
   }
   catch(e){
      alert("Error number: " + e.number + "; Description: " + e.description)
   }   
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="theForm">
Enter text for the error:
<INPUT type=text name=errText size=40>
<INPUT type=button name=btnThrow value="Throw it!" onClick="throwError(document.theForm.errText.value);">
</FORM>  
</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)