Overview

This project provides libraries for Java to make exception handling in applications and libraries easier.

At the heart of the library there is an exception class that provides three fundamental informations.

  1. Unique exception identifier
  2. Exception code
  3. time at which the exception has been raised

An additional service is to truncate the root causes of an exception.

Unique Exception Identifier

The unique exception identifier helps to track exceptions over various modules even on different systems. If you try to track the exception on the client back to the system that actually raised the exception, this identifier is very handy.

The library is flexible in how to generate this identifier. It provides two implementations:

Name Description
de.smartics.exceptions.id.IncrementFactory (source) Provides positive long values as identifier.
de.smartics.exceptions.id.UuidFactory (source) Provides UUID values as identifier.

Exception Code

The exception code classifies the exception that has been raised. The exception code has a string representation that can be displayed to the user or logged to a log file.

As with exception identifiers you are free to implement your own representation of exception (or error codes). The Code interface provides two pieces of information:

Name Description
component identifier Identifies the component/library that raised the exception.
exception code identifier This code identifies what kind of problem has been encountered.

This library provides two implementations of the Code interface (by defining a sub interface called NumberCode that structures the exception code identifier in a major and minor number):

Name Description
de.smartics.exceptions.code.NumberCodeInfo (source) Simply adds the major and minor number.
de.smartics.exceptions.code.TwoNumberCodeInfo (source) Separates the major and minor number by a '-' in its string representation.

Time

The time stamp logs when the exception has been created. The logging framework normally will log the time the exception has been encountered, but associating this information with the exception will help to visualize the time even if the exception occurred earlier and will not change even if the exception is displayed multiple times (as in a GUI dialog).

Stripping the Cause of Exceptions for Delivery

If an exception is thrown over system boundaries, the classes for some cause exceptions may not be present on the remote VM. This project provides a simple (and crude) mechanism to remove the cause stack from an exception prior to throwing it.

This service is experimental and helps as a final line of defense to remove specific exception from the exception stack.