void () { Alarm alarm = new Alarm(getTestRootDisposable()); Throwable error = LoggedErrorProcessor.executeAndReturnLoggedError(() -> { alarm.addRequest(() -> { throw new RuntimeException("wtf"); }, 1); boolean caught = false; while (!alarm.isEmpty()) { try { UIUtil.dispatchAllInvocationEvents(); } catch (RuntimeException e) { caught |= "wtf".equals(e.getMessage()); } } assertTrue(caught); }); assertEquals("wtf", error.getMessage()); }