Defines standard exception hierarchy for applications.

Package Specification

Correct and consistent exception handling is paramount to ultimate success of a project. This package attempts to define a standard set of exceptions, which is the first step on the way to achieve that goal.

From the conceptual standpoint there are two fundamental types of exceptions: business exception and non-business exception also known as application exception. Business exceptions occur when business constraints are violated. Application exceptions usually denote flaws in the code (application bugs) or environmental issues such as runtime network and connectivity problems.

Business Exceptions

Business exceptions are usually caused by invalid input from the end user or by illegal sequence of user actions. Business logic programmers do expect them to happen from time to time. Therefore, application code must catch all business exceptions and display appropriate business friendly messages to the user. It is responsibility of the user to correct the issue. BusinessException class defined in this package serves as a base class for all such situations. It descends from java.lang.Exception and therefore is a checked exception that must be declared or handled by any method where it can originate.

Business code developers can define and use any number of concrete business exceptions that inherit from BusinessException.

Application Exceptions

Application exceptions are either programming bugs or environmental issues that the end users have no control over. Since most of the application exceptions are result of the coding errors, application code developers do not know when they occur. Had they known they would have fixed them. As such, application exceptions are non-checked runtime exceptions that don't have to be declared.

Application exceptions are physically separated from business exceptions in their own hierarchy parented by AppException. This base exception class provides methods to add full exception context information to be used to diagnose the root cause and circumstances of the error. It also allows handling of application exceptions as a group if needed. AppException is defined as abstract class due to its generic nature. It can not be thrown directly.

The hierarchy of application exception classes is very flat. Concrete application exceptions such as AppArgumentException derive directly from AppException. They are designed as a closed set to represent major root causes of application errors. Each one of them has a well known meaning and should be used accordingly. For example, AppUnsupportedException should only be thrown when an unsupported operation is invoked, AppSecurityException must be thrown when application code allowed access to a forbidden resource, AppArgumentException must be thrown when illegal interface arguments are detected and so on.

Business code developers should not define their own application exception classes. Only well known pre-defined exception classes provided by this package must be used. This will ensure correctness and consistency of the exception handling mechanism developed within the constraints of this exception handling framework. @since 12/15/2004