Table of Contents
A programmer who makes use of the Tensegrity API expects it to behave in a predictable way. In the Java programming language, throwing exceptions is the preferred way of reporting unusual behaviour caused when invoking a method. The Tensegrity API therefore defines a set of unique exception classes which report such error conditions. Java® distinguishes between runtime exceptions and static exceptions.
Runtime exceptions are dynamic exceptions and do not need to be declared at
compile time because they are recognized as such by their superclasses. All
dynamic exceptions are subclasses of
java.lang.RuntimeException
.
These exceptions are not necessarily part of a method's signature.
All dynamic exceptions thrown by the Tensegrity API are subclasses of the custom
exception com.tensegrity.generic.util.DynamicException
.
This convention allows users to distinguish between exceptions which are
thrown by the Tensegrity API and all other runtime exceptions.
To give you an idea as to which runtime exceptions are implemented
in the current version of the Tensegrity API, the following table lists all
exception classes which extend class
com.tensegrity.generic.util.DynamicException:
Table 15.1. Exceptions extending DynamicException
| Exception | Description |
|---|---|
AssertException |
Thrown when an assertion check fails. |
CustomConstraintException |
Thrown when a |
DynamicAttributeException |
Thrown when an exception involving an |
GraphDynamicException |
This represents the base exception class for graphs. |
IllegalElementException |
Thrown by an iterator if an |
InvalidArgumentException |
Thrown whenever an invalid argument is passed to a method, including constructors. |
ListModifiedException |
Thrown if an |
MathDynamicException |
Thrown if mathematical calculations have to be interrupted, for example resulting from a division by zero. |
PreferenceException |
Thrown whenever an error occurs while working with |
RuleDynamicException |
Thrown if a rule operation fails. |
UnsupportedMethodException |
Thrown if the called method is not implemented by the receiving object. |
VisualSubgraphUnchangedNotificationException |
Thrown by a |
XMLParseException |
Thrown when an |
Catching exceptions thrown from the Tensegrity API is a simple task. A “lazy programmer” may choose to only catch the basic runtime exceptions and extract the associated exception messages or propagate the exception type by using the getClass() method of the exception. This is not a recommended practice, however, but may save additional typing effort when writing unit tests or other nonproduction code.
© 2004, 2005 Tensegrity Software GmbH