JavaScript
  Home arrow JavaScript arrow Exception Handling in JavaScript: Catching...
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: Catching User Input
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2005-09-27

    Table of Contents:
  • Exception Handling in JavaScript: Catching User Input
  • Using multiple error handlers: a quick overview of the previous script
  • Catching user data: triggering errors through web forms
  • A quick and dirty error handler: using JavaScript prompts

  • 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: Catching User Input


    (Page 1 of 4 )

    In a previous article, Alejandro Gervasio explained some key concepts related to working with primary error types, and how they are raised by JavaScript interpreters. This article will focus on developing specific sample code for trapping most of the primary error types according to data entered by users.

    Introduction

    This is the third part of the series “Exception handling in JavaScript.” Welcome back. Throughout the previous part, I explained some key concepts related to working with primary error types, along with using multiple exception handlers for trapping different raised errors. Of course, numerous examples were demonstrated, aimed primarily at exposing clearly how most primary error types can be deliberately triggered. In this way, it’s possible to implement the proper error handlers and see how JavaScript code can react and handle unexpected conditions during program execution.

    If you’ve been playing around with the examples that I showed in the previous tutorial, then you already have a pretty clear idea of how primary error types are raised by the vast majority of JavaScript interpreters. Although sample code isn’t meant for the production environment, it does illustrate core concepts inherent to implementing “try-catch” blocks within JavaScript programs, with the goal of making them look more professional from a programming point of view. As you know, exceptions allow you to establish specific fragments of code for trapping raised errors, while maintaining “regular” routines focused on dealing with normal and expected situations.

    This powerful ability can make a big difference, particularly when working with large applications, where centralized error handling is often required, by introducing a considerable impact on JavaScript code development.

    By returning to the objectives of this third part of the series, strong attention will be put on developing specific sample code focused on trapping most of the primary error types according to data entered by users. Hopefully the experience will be instructive enough to illustrate how primary errors can be caught by the appropriate error handlers, based on user-provided input.

    Now that you have a clear idea of the topics to be treated in this article, we can move on to writing the complete scripts for working with user-supplied data.

    More JavaScript Articles
    More By Alejandro Gervasio


       · The third part of the series demonstrates how to deliberately raise errors, in order...
     

    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 4 hosted by Hostway