Balázs Szabó worked in a large company maintaining a few modules within a huge J2EE system. The system was notorious for its complete lack of error handling, providing users (and developers) with a simple message of failure:

An unexpected exception occurred. Please try again.

The architecture team was commissioned to develop enterprise exception handling so that users would get a better indication of the error and developers could check logs to see what went wrong. However, after their system went into production, some very strange error messages started popping up, often times completely unrelated to the apparent problem ...

There was a problem validating your name and password: 
  SQL009-Unable to insert duplicate key into index PRODUCT_MGMT_PK.

Balázs took the liberty to investigate the strange messages and found the following code in the logon data-access class ...

DataNotFoundException.getInstance().setMessage(errMsg);
throw DataNotFoundException.getInstance();

... and, as one might expect, DataNotFoundException was implemented as a singleton, as were all other exception classes. A rather interesting choice for what was a high-traffic J2EE web application in a multithreaded environment ...

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!