The Artima Developer Community
Sponsored Link

Java Buzz Forum
Three Rules for Effective Exception Handling

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Goldy Lukka

Posts: 1008
Nickname: xyling
Registered: Jan, 2004

Goldy Lukka is a Java Developer and an Entrepreneur. He is Founder of xyling.com.
Three Rules for Effective Exception Handling Posted: Sep 5, 2006 7:11 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Goldy Lukka.
Original Post: Three Rules for Effective Exception Handling
Feed Title: Xyling Java Blogs
Feed URL: http://www.javablogs.xyling.com/thisWeek.rss
Feed Description: Your one stop source for Java Related Resources.
Latest Java Buzz Posts
Latest Java Buzz Posts by Goldy Lukka
Latest Posts From Xyling Java Blogs

Advertisement
Exceptions in Java provide a consistent mechanism for identifying and responding to error conditions. Effective exception handling will make your programs more robust and easier to debug. Exceptions are a tremendous debugging aid because they help answer these three questions:

What went wrong?
Where did it go wrong?
Why did it go wrong?

Here are the three rules for effective exception handling:

1. Be Specific (i.e. Define your custom exception to give more precise information about the exception that has occured).

2. Throw early (if you find an errorneous piece of information/code, throw the exception then and there instead of letting it flow to the next level). e.g. before opening a file check if the fileName string is null and throw an exception before a NullPointerException is thrown with a trace of FileNotFoundException.

3. Catch Late (if you encounter an exception, do not proceed with the remaining tasks if they are related/dependent on the earlier ones).

To read the full article, point to the title of this post.

[Resource-Type: Article, Category: Java/Exception Handling,XRating: 4,Level: All]

Read: Three Rules for Effective Exception Handling

Topic: Firefox Extension Showcase - Simplifies Tab Browsing Previous Topic   Next Topic Topic: XhtmlValidator 0.2 released

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use