Concordion > Commands > "execute" >

"Fail-fast" with specific exceptions

Fixtures can be annotated with @FailFast to stop further processing if any exception is encountered. (More details)

However, it can be useful to fail-fast on some exceptions but not others. The @FailFast annotation can be supplied with a list of exception types. In this case, processing will only be stopped if an exception is encountered that is an instance of one of the exception types in the list.

Example - non matching exception

When the fixture is annotated with @FailFast(onExceptionType={RuntimeException.class, IOException.class}) and processes the following:

<p concordion:execute="myTimeoutExceptionThrower()">
This method throws a TimeoutException (which is not a subclass of RuntimeException or IOException).
</p>

<p concordion:execute="myMethod()">
This method executes quietly.
</p>

It calls myMethod() in the Java fixture code because the TimeoutException thrown by the first method call does not stop further processing of the test.

Example - matching exception

When the fixture is annotated with @FailFast(onExceptionType={RuntimeException.class, IOException.class}) and processes the following:

<p concordion:execute="myFileNotFoundExceptionThrower()">
This method throws a FileNotFoundException (which is a subclass of IOException).
</p>

<p concordion:execute="myMethod()">
This method executes quietly.
</p>

It does not call myMethod() in the Java fixture code because the FileNotFoundException thrown by the first method call stops further processing of the test.