Home arrow JavaScript arrow Exception Handling in JavaScript: Using Multiple Exception Handlers

Exception Handling in JavaScript: Using Multiple Exception Handlers

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.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
September 20, 2005
  1. · Exception Handling in JavaScript: Using Multiple Exception Handlers
  2. · Handling multiple errors: stepping back to the first example
  3. · Working with primary error types: defining error types for the JavaScript 1.5 specification
  4. · A practical example: trapping multiple error types
  5. · Using multiple handlers: working with “if-else if” blocks

print this article

Exception Handling in JavaScript: Using Multiple Exception Handlers
(Page 1 of 5 )

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.

blog comments powered by Disqus

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials