Throwing Exceptions
Jakob Jenkov |
Throwing exception is the next step after error detection and information gathering. When you detect an error, you need to determine if you need to throw an exception, and what information to include in that exception.
What information to embed in the exception is determined in the previous stage - Error Information Gathering
Here is a simple example:
String errorId = ... String errorDescription = ... String contextId = .... throw new MyException(errorId, errorDescription, contextId);
Later in this tutorial trail I will show you an Exception class definition that is much better suited to address the requirements listed earlier in this trail.
Next: Propagating Exceptions
Tweet | |
Jakob Jenkov |