- Exception Handling Strategies
- Exception Handling Strategy - Overview
- Exception Handling Requirements
- Application Survival
- Notifying Relevant Parties
- Error Diagnostics and Reproduction
- Separation of Abstraction Layers
- More Readable and Maintainable Code
- Error Location and Context
- Error Causes, Types and Reactions
- Strategy Elements
- Error Detection
- Error Information Gathering
- Throwing Exceptions
- Propagating Exceptions
- Catching Exceptions
- An Exception Handling Strategy Template
- An Exception Class Template
- Throwing the AppException
- Propagating the AppException
- The ErrorInfo List
- Catching the AppException
- Avoid Exception Hierarchies
Exception Handling Requirements
The purpose of an effective exception handling strategy can be grouped into a set of primary and secondary purposes, or requirements as we like to call them in software development. The requirements state what should happen if an exception (error) occurs in an application.
The primary requirements are the most important to meet with your exception handling strategy. The secondary requirements are not nearly as important, but it is still a good idea to take these into consideration, if you have the time and opportunity in your project.
The primary requirements of an effective exception handling strategy are:
- The application survives the exception and can continue to process events, requests, files etc. Or, the application shuts down gracefully.
- The relevant parties are notified. These parties include:
- End users
- System operators and administrators
- Customers / owners of the application
- The exception / error can be diagnosed and reproduced, so it can be corrected.
The secondary goals of an effective exception handling strategy are:
- Encapsulation / Separation of abstraction layers.
- More readable, maintainable code.
Both primary and secondary requirements are explained in more detail in the following texts.