§6.2.(d) Exceptions
The following Exceptions
can be thrown during the execution of an ObjectTeam/Java program:
ResultNotProvidedException
- Thrown if a replace callin without a base call does not provide the necessary (primitive type) base result
(see §4.3.(e)).
LiftingFailedException
- Thrown if an actual ambiguity occurs during lifting (see §2.3.4.(c))
or if lifting would need to instantiate an abstract role class (see §2.5.(b)).
This is a checked exception.
See §2.3.5 for more information.
WrongRoleException
- Thrown during lifting if the base object has, with respect to the same team instance, previously been lifted
to a role type that is not conform to the currently requested type
(see §2.3.4.(d) and §2.4.3).
DuplicateRoleException
- Thrown during explicit role creation, if a new role is created for a base object, which already has a role
of the required type in the given team (see §2.4.1.(c)).
RoleCastException
- Thrown during cast of an externalized role, if the casted expression is anchored to a different team instance
than the cast type (see §1.2.4.(b)).
LiftingVetoException
- This exception is used internally to abort the process of lifting when a relevant guard predicate (§5.4) evaluated to false.
Such exceptions thrown from generated code will never appear in client code, so there is usually no need to catch a
LiftingVetoException
.
However, in some situations it is useful to explicitly throw a LiftingVetoException
from a lifting constructor (§2.3.1.(b)) of a role.
This style allows to abort lifting even after the lifting constructor has started to work and also for method parameters
requiring lifting.
If lifting was triggered due to a callin method binding, this binding will simply not trigger if a LiftingVetoException
is thrown
while preparing the call to the role method.