Basic Use

In general either an Alert is thrown specifically, or a standard Java exception is caught and re-thrown as an Alert.

Here's a simple overview of how to throw an Alert:

throw new Alert( "COMPLAINT", "EXPLANATION" ).culprit( "TYPE", "VALUE" ).mishap();

The mishap method throws itself, so in some situations you can avoid the explicit throw. There is also an alternative method, warning, which issues the Alert as a warning. A warning reports the Alert, but doesn't throw it.

Here's a example alert::

throw new Alert( "My head hurts", "Too much beer drunk" ).culprit( "pints", "15" ).mishap();

Which would be reported as:

MISHAP : My head hurts
BECAUSE : Too much beer drunk
PINTS : 15

Alerts also have the concept of an origin and can have custom decoration. An origin specifies the source of the problem and/or the relevant line number. A decorator can be used to attach additional information to the Alert. A decorator is only allowed to decorate a given Alert once, while the origin can only be set once.