JavaScript Exception Handling - Endzone (
Page 8 of 8 )
And that just about covers it. In this article, I took you on a guided tour
of exception handling in JavaScript, demonstrating how the "try" and
"catch" blocks can be used to trap and resolve errors in script execution.
I showed you how to retrieve the exception type and message, write exception
handlers for different error types, and even generate your own custom errors.
Finally, I wrapped things up with a real-world example that demonstrated how
to build a simple form validator and generate exceptions suitable for processing
by a generic "try-catch" handler.
In case you'd like to learn more about these topics, you should consider visiting
the following links:
The official ECMAScript reference, at http://www.ecma-international.org/publications/standards/ecma-262.htm
JavaScript 1.5 reference material in the Netscape DevEdge documentation, at
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/st
mt.html#1051663
Handling errors in Internet Explorer, at http://msdn.microsoft.com/library/en-us/dnscrpt/html/WebErrors2.asp
Until next time...be good!
Note: Examples are illustrative only, and are not meant for a production environment.
Code samples in this article have been tested on Microsoft Internet Explorer
6.0. Melonfire provides no warranties or support for the source code described
in this article. YMMV!