Quick References
ADO
ASP
CSS2
HTML
JavaScript
Jet SQL
VBScript
WML
WMLScript
WSH
XHTML
XML DOM
XSLT
Features
Knowledge Base
Tutorials
Partners
ZVON.ORG
XML
Planet Source Code
VisualBuilder
Web Design
Your HTML Source
XML/XSLT Forums
ASPAlliance
Scripts
Programmers Heaven
Tek-Tips Forums
Developer Fusion
Code Project
All Statements
try...catch
STATEMENT: throw
throw
(exception)
The
throw
statement allows the programmer to create an exception. This
exception
can be a string, integer, Boolean or an object. Coupling the
throw
statement with the
try...catch
statement, the programmer can control program flow and generate accurate error messages.
The following example determines the value of variable(z), and generates an error accordingly. This error is then caught by the
catch
argument and the proper error message is then displayed.
Code:
try {
if(z == 1)
throw "Error 1"
else if(z == 2)
throw "Error 2"
}
catch(er) {
if(er == "Error 1")
alert("Error 1 Please contact system Administrator")
if(er == "Error 2")
alert("Error 2 Please Reload the page")
}
Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information