In Play, it seems that if an exception is thrown inside a Job<T>, the exception does not propagate outward.
If I understand correctly, in order to know if the inner code throws an exception, I must revert to using boolean return values (a known anti pattern)? Or am I missing something?
Here is a code sample that does not throw anything, but rather renders the todo page – and I would like to know how to know the inner job threw an exception from the outer controller method:
public static void testException() throws ExecutionException, InterruptedException {
F.Promise<Void> result = new Job<Void>() {
@Override
public void doJob() throws Exception {
Thread.sleep(1000);
throw new RuntimeException("Foo");
}
}.now();
await(result);
result.get();
todo();
}
I’m just using a
Job<Boolean>instead and returningtrueon success.