spacer
Yehuda Shiran September 13, 2002
Processing in the try, catch, and finally Blocks
Tips: September 2002

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

The try...catch...finally statement in JScript .NET lets you handle the errors that may occur in the try block. If an error occurs in the try block, program control is passed to the catch block. The value passed to the catch block as a parameter is the value of the error that occurred in the try block. If no error occurs, the catch block is not executed. For errors that you don't handle in the catch block, JScript .NET provides its normal error message to the user, as if there was no error handling. But remember, avoid showing system errors to the user, as they may give the impression of buggy and sloppy coding.

After all statements in the try block have been executed and any error processing has been completed in the catch block, the finally block is unconditionally executed. The code inside the finally block is always executed. Even if the catch block re-throws the error or if a return statement occurs inside the catch or try blocks, the finally block is guaranteed to run. The only exception is when an unhandled error occurs; in this case, the system processes this run-time error by printing a message to the user and quitting from the JScript .NET application.

To learn more about exception handling, go to Column 118, JScript .NET, Part XII: Exception Handling.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business