Throwing an Error : JavaScript DHTML examples (example source code) » Development » Error Exceptions

JavaScript DHTML










Java Products
Java Articles
JavaScript DHTML Home  »   Development   » [  Error Exceptions  ]   

 
Throwing an Error

Please note that some example is only working under IE or Firefox.

/*

Learn How to Program Using Any Web Browser
by Harold Davis 

Apress CopyRight 2004

ISBN: 1590591135
*/
<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>
<H1> 
Throw that error! 
</H1>
<FORM name="theForm">
<TABLE>
<TR>
<TD colspan=2
Enter text for the error: 
</TD>
<TD>
<INPUT type=text name=errText size=40>
</TD>
</TR>
<TR>
<TD colspan=2>
</TD>
<TD>
<INPUT type=button name=btnThrow value="Throw it!" 
   onClick="throwError(document.theForm.errText.value);">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
Related examples in the same category
1.  Catching the 'Object Expected' Error
2.  Catching an Error
3.  Controlling Script Errors
4.  An Exception Handling Example
5.  Nested Exception Handling
6.  Using the onError Event Handler
7.   Throwing String Exceptions
8.  Throwing an Error Object Exception
9.  A Custom Object Exception
10.  Use the try catch to handle exceptions








Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.