Exception Handling Strategies
Introduction
Overview
Requirements
   Application Survival
   Notifying Relevant Parties
   Error Diagnostics
   Separation of Abstr. Layers
   Maintainable Code
 
Error Location and Context
Error Causes, Types and Reactions
 
Strategy Elements
   Error Detection
   Error Info Gathering
   Throwing Exceptions
   Propagating Exceptions
   Catching Exceptions
 
A Strategy Template
   AppException Template
   Throwing the AppException
   Propagating the AppException
   The ErrorInfo List
   Catching the AppException
 
Execution Context
Avoid Exception Hierarchies
 


Exception Handling Strategies

Connect with me:  
  Jenkov.com - News

In my work as consultant I often get to look into a clients existing applications. The exception handling I see in these applications is anywhere from almost random, to almost useful. There is often no formal, coherent exception handling strategy. Or, there is a strategy, but it is insufficient, meaning it does not contain all the rules, information and precautions necessary to fully handle all exceptions. That's why I decided to write this trail on exception handling strategies.

You may have noticed my trail on Java Exception Handling, which contains a list of text explaining a set of basic exception handling techniques. That trail however, does not cover how to put all these techniques into a coherent exception handling strategy.

In this trail I will explore how to put all the individual exception handling techniques into a single, coherent exception handling strategy. Don't treat this strategy as the one-and-only strategy possible. Treat it as a template for your own exception handling strategy. A suggestion, in other words. Make the adjustments you want or need in your concrete situation.

The exception handling strategy presented in this trail is language independent. You can implement this strategy in pretty much any language which has a try-catch-finally mechanism, including Java, Scala, C# etc.

Being an exploration of the subject, the suggestions inhere may be able to be improved. If you have any suggestions or comments, I will be happy to hear from you. I may also update this trail over time myself, as I get more knowlegde on the topic.


Table of Contents

Here is a list of the topics covered in this trail. This list (menu) is also present at the top right of every page in the trail.

  Exception Handling Strategies
Introduction
Overview
Requirements
   Application Survival
   Notifying Relevant Parties
   Error Diagnostics
   Separation of Abstr. Layers
   Maintainable Code
 
Error Location and Context
Error Causes, Types and Reactions
 
Strategy Elements
   Error Detection
   Error Info Gathering
   Throwing Exceptions
   Propagating Exceptions
   Catching Exceptions
 
A Strategy Template
   AppException Template
   Throwing the AppException
   Propagating the AppException
   The ErrorInfo List
   Catching the AppException
 
Execution Context
Avoid Exception Hierarchies
 

Feel Free to Contact Me

If you disagree with anything I write here about exception handling strategies, or just have comments, questions, etc, feel free to send me an email. You wouldn't be the first to do so. You can find my email address on the about page.

Connect with me:
     
Newsletter - Get all my free tips!