Catch an error (IE) : Error : Development JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Development » Error »

 

Catch an error (IE)

















<HTML>
<HEAD>
   <TITLE>Catch that error!</TITLE>
<SCRIPT>
function catchError(errString) {
   try {
      try {
            throw new Error (42"errString is 42!");
      }
      catch(e) {
         if (e.number == 42)
            return (e.description + " Got this one!");
         else
            throw e; 
      
   }
   catch (e){
      return(e.description + " This one not handled here!");
   
}
</SCRIPT>
</HEAD>
<BODY>
<FORM name="theForm">
<INPUT type=text name=errText size=40 value="42">
<INPUT type=button 
       name=btnThrow 
       value="Catch it!" 
       onClick="alert(catchError(document.theForm.errText.value));">
</FORM>  
</BODY>
</HTML>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Development
» Error