Tech and Media Labs
This site uses cookies to improve the user experience.




Throwing Exceptions

Jakob Jenkov
Last update: 2014-05-26

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.

Jakob Jenkov




Copyright  Jenkov Aps
Close TOC