Powered by Olark
Real Estate Web Site Design - Site Map Javascript::Javascript-Exception Handling
HomeContactSearchSite MapMore Information
Web Content Solutions
 
 
 
Support Login
    
     SOLUTIONS    >Content    >Hosting   >eCommerce   >Off-Site Customer Support   >Consultation

Javascript::Javascript-Exception Handling

Exception handling

Exception handling is a programming language construct or computer hardware mechanism designed to handle runtime errors or other problems (exceptions ) which occur during the execution of a computer program.

In general, current state will be saved in a predefined location and execution will switch to a predefined handler. Depending on the situation, the handler may later resume the execution at the original location, using the saved information to restore the original state. For example, an exception which will usually be resumed is a page fault, while a division by zero usually cannot be resolved transparently.

From the processing point of view, hardware interrupts are similar to resumable exceptions, except they are usually not related to the current program flow.

Exception handling is intended to facilitate use of reasonable mechanisms for handling erroneous or exceptional situations that arise in programs. Exception handling can be used to pass information about error situations that occur within library code to its users, and selectively respond to those errors.

A possible role of exception handling is to allow the program to continue its normal operation and prevent crashing and displaying of cryptic error messages to the user. In many cases, it is sufficient to stop the program and produce an error report; the difference with systems that do not use exceptions to signal improper program executions is that with proper exception handling, the erroneous condition may be pointed precisely, whereas otherwise it is often detected later, making debugging difficult.

Newer versions of JavaScript (as used in Internet Explorer 5 and Netscape 6) include a try ... catch ... finally exception handling statement. Purloined from the Java programming language, this is intended to help with run-time errors but does so with mixed results.

The try ... catch ... finally statement catches exceptions resulting from an error or a throw statement. Its syntax is as follows:

try {
  // Statements in which exceptions might be thrown
} catch(error) {
  // Statements that execute in the event of an exception
} finally {
  // Statements that execute afterward either way
}

Initially, the statements within the try block execute. If an exception is thrown, the script's control flow immediately transfers to the statements in the catch block, with the exception available as the error argument. Otherwise the catch block is skipped. Once the catch block finishes, or the try block finishes with no exceptions thrown, then the statements in the finally block execute. This is generally used to free memory that may be lost if a fatal error occurs—though this is less of a concern in JavaScript. This figure summarizes the operation of a try...catch...finally statement:

try {
  // Create an array
  arr = new Array();
  // Call a function that may not succeed
  func(arr);
}
catch (...) {
  // Recover from error
  logError();
}
finally {
  // Even if a fatal error occurred, we can still free our array
  delete arr;
}
 

The finally part may be omitted:

try {
  statements
}
catch (err) {
  // handle errors
}

..

Javascript::Javascript-Exception Handling Related Sites

[READ MORE : Javascript::Javascript-Exception Handling]

Real Estate Web Design Real Estate Web Design

Real Estate Web Site Design is a great place to start for Real Estate Web Design Real Estate Web Site Design is what Web Content Solutions specializes in.
If you are looking for Real Estate Web Design Real Estate, you've come to the right place.
Our Real Estate Web Design Real Estate web site design specializes in Real Estate Web Design real estate web design.
Thank you for taking the time to visit my Real Estate Web Design Real Estate web site.
Feel free to use my Real Estate Web Design real estate home search. Search Real Estate Web Design Real Estate Now!