Verify the Exception Payload
We can generalize the idea of verifying the exception message. In the last section, we made a deliberate decision to temporarily ignore the cause of the exception, the other of the two attributes that could help us distinguish why the exception was thrown. We could have used the cause as an alternative means of verification or even to supplement our verification. In fact, the
cause are the only user-settable attributes2 of the
Throwable class, the base class for exceptions of all types3 in Java.
Throwable closely resembles the base class of exception hierarchies in other languages and frameworks. For example, C# has the
System.Exception class that has
Message attributes. C++ has only ...