use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class AbstractDesktopExtension method contributeOutlines.
@Override
public void contributeOutlines(OrderedCollection<IOutline> outlines) {
List<Class<? extends IOutline>> contributedOutlines = getConfiguredOutlines();
if (contributedOutlines == null) {
return;
}
for (Class<? extends IOutline> element : contributedOutlines) {
try {
IOutline o = element.newInstance();
outlines.addOrdered(o);
} catch (Exception t) {
BEANS.get(ExceptionHandler.class).handle(new ProcessingException("error creating instance of class '" + element.getName() + "'.", t));
}
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class TableUserFilterManager method getSerializedData.
/**
* Get the serialized data of the UserFilterManager for further processing (e.g. storing a bookmark)
*/
public byte[] getSerializedData() {
byte[] data = null;
try {
// Create array list because m_filterMap.values() is not serializable
Collection<IUserFilterState> filterStates = new ArrayList<>(m_filterMap.values());
data = SerializationUtility.createObjectSerializer().serialize(filterStates);
} catch (Exception t) {
throw new ProcessingException("Failed creating user filter data.", t);
}
return data;
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class WhenDoneTest method testError.
@Test
public void testError() throws InterruptedException {
// synchronized because modified/read by different threads.
final List<String> protocol = Collections.synchronizedList(new ArrayList<String>());
final Holder<DoneEvent<String>> eventHolder = new Holder<>();
final ProcessingException pe = new ProcessingException("expected JUnit test exception");
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
protocol.add("1");
throw pe;
}
}, Jobs.newInput().withExceptionHandling(null, false).withExecutionTrigger(Jobs.newExecutionTrigger().withStartIn(1, TimeUnit.SECONDS)));
final BlockingCountDownLatch verifyLatch = new BlockingCountDownLatch(1);
future.whenDone(new IDoneHandler<String>() {
@Override
public void onDone(DoneEvent<String> event) {
protocol.add("2");
if (future.isDone()) {
protocol.add("done");
}
if (future.isCancelled()) {
protocol.add("cancelled");
}
eventHolder.setValue(event);
verifyLatch.countDown();
}
}, RunContexts.copyCurrent());
assertTrue(verifyLatch.await());
assertEquals(CollectionUtility.arrayList("1", "2", "done"), protocol);
assertSame(pe, eventHolder.getValue().getException());
assertNull(eventHolder.getValue().getResult());
assertFalse(eventHolder.getValue().isCancelled());
assertTrue(eventHolder.getValue().isFailed());
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class WhenDoneTest method testErrorWithJobAlreadyCompleted.
@Test
public void testErrorWithJobAlreadyCompleted() throws InterruptedException {
// synchronized because modified/read by different threads.
final List<String> protocol = Collections.synchronizedList(new ArrayList<String>());
final Holder<DoneEvent<String>> eventHolder = new Holder<>();
final Exception error = new ProcessingException("expected JUnit test exception");
final IFuture<String> future = Jobs.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
protocol.add("1");
throw error;
}
}, Jobs.newInput().withExceptionHandling(null, false));
try {
future.awaitDoneAndGet();
fail("exception expected");
} catch (ProcessingException e) {
final BlockingCountDownLatch verifyLatch = new BlockingCountDownLatch(1);
future.whenDone(new IDoneHandler<String>() {
@Override
public void onDone(DoneEvent<String> event) {
protocol.add("2");
if (future.isDone()) {
protocol.add("done");
}
if (future.isCancelled()) {
protocol.add("cancelled");
}
eventHolder.setValue(event);
verifyLatch.countDown();
}
}, RunContexts.copyCurrent());
assertTrue(verifyLatch.await());
assertEquals(CollectionUtility.arrayList("1", "2", "done"), protocol);
assertSame(error, eventHolder.getValue().getException());
assertNull(eventHolder.getValue().getResult());
assertFalse(eventHolder.getValue().isCancelled());
assertTrue(eventHolder.getValue().isFailed());
}
}
use of org.eclipse.scout.rt.platform.exception.ProcessingException in project scout.rt by eclipse.
the class JobScheduleTest method testProcessingExceptionWithCallable.
@Test
public void testProcessingExceptionWithCallable() {
final ProcessingException exception = new ProcessingException("expected JUnit test exception");
IFuture<Void> future = Jobs.getJobManager().schedule(new IRunnable() {
@Override
public void run() throws Exception {
throw exception;
}
}, Jobs.newInput().withRunContext(RunContexts.copyCurrent()).withExceptionHandling(null, false));
try {
future.awaitDoneAndGet();
fail("Exception expected");
} catch (Exception e) {
assertSame(exception, e);
assertTrue(future.isDone());
}
}
Aggregations