JavaScript
  Home arrow JavaScript arrow Exception Handling in JavaScript: Using Mu...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Exception Handling in JavaScript: Using Multiple Exception Handlers
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2005-09-20

    Table of Contents:
  • Exception Handling in JavaScript: Using Multiple Exception Handlers
  • Handling multiple errors: stepping back to the first example
  • Working with primary error types: defining error types for the JavaScript 1.5 specification
  • A practical example: trapping multiple error types
  • Using multiple handlers: working with “if-else if” blocks

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Exception Handling in JavaScript: Using Multiple Exception Handlers


    (Page 1 of 5 )

    In this article, you will learn how to work with multiple exception handlers in JavaScript, and deal with primary error types. This will be illustrated by several examples, to get you familiar with JavaScript exceptions.

    Welcome to the second part of the series “Exception Handling in JavaScript”. Throughout the first article of the series, I introduced the basics of JavaScript exceptions by explaining the role of the “throw” statement, together with the popular exception handling combination comprised of “try-catch” blocks.

    In conjunction with the explanations about the corresponding core concepts, I set up some illustrative examples, in order to demonstrate how simple application layers can be conceived and written by establishing a logic aimed at clearly delineating code responsibility. As described previously, exceptions allow you to easily separate code for dealing with normal program execution from routines specifically programmed to handle raised errors.

    It should be noted, though, that the examples were extremely simple and implemented a basic approach for handling a few triggered errors. In general, it’s a poor programming practice to catch all errors without checking their type, or even worse, ignore them completely. That’s why I suggest that you start using “try-catch” blocks within your JavaScript programs, and configure the appropriated exception handler accordingly, to treat specific types of errors.

    Since different errors could occur during the execution of an application, the topic brings us to the subject of this second part. Over the course of this article, I’ll  explain specific types of errors that JavaScript interpreters may eventually trigger, together with the implementation of multiple exception handlers, in order to trap errors through a more professional technique.

    With the goals of the article already established, let’s move forward to learn more about JavaScript exceptions.

    More JavaScript Articles
    More By Alejandro Gervasio


       · This second tutorial is primarily focused on explaining how to use multiple...
     

    JAVASCRIPT ARTICLES

    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget
    - Ajax Hack for Entering Information Without R...
    - EXT JS 2.1 Overview
    - Using the Style Object for Zebra Tables with...
    - Binary Searching
    - An Improved Approach to Building Zebra Tables
    - Assigning Background Colors Dynamically to Z...
    - Building Zebra Tables with CSS and JavaScript
    - JavaScript: Array Objects
    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway