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 message and 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 InnerException and Message attributes. C++ has only ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access