use of org.eclipse.scout.rt.platform.exception.ExceptionHandler in project scout.rt by eclipse.
the class ExceptionProcessorTest method testWithCustomExceptionHandler.
@Test
public void testWithCustomExceptionHandler() throws Exception {
final RuntimeException exception = new RuntimeException("expected JUnit test exception");
final AtomicReference<Throwable> error = new AtomicReference<>();
JobInput jobInput = Jobs.newInput().withExceptionHandling(new ExceptionHandler() {
@Override
public void handle(Throwable t) {
error.set(t);
}
}, true);
CallableChain<String> chain = new CallableChain<>();
chain.add(new ExceptionProcessor<String>(jobInput));
chain.call(new Callable<String>() {
@Override
public String call() throws Exception {
throw exception;
}
});
assertSame(exception, error.get());
verify(m_exceptionHandler, never()).handle(eq(exception));
}
use of org.eclipse.scout.rt.platform.exception.ExceptionHandler in project scout.rt by eclipse.
the class ThrowHandledExceptionStatement method evaluate.
@Override
public void evaluate() throws Throwable {
m_next.evaluate();
// Re-throw the first handled exception if 'JUnitExceptionHandler' is installed as exception handler.
final ExceptionHandler exceptionHandler = BEANS.get(ExceptionHandler.class);
if (exceptionHandler instanceof JUnitExceptionHandler) {
((JUnitExceptionHandler) exceptionHandler).throwOnError();
}
}
Aggregations