Search in sources :

Example 1 with ProcessingException

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));
        }
    }
}
Also used : IOutline(org.eclipse.scout.rt.client.ui.desktop.outline.IOutline) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) VetoException(org.eclipse.scout.rt.platform.exception.VetoException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 2 with ProcessingException

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;
}
Also used : IUserFilterState(org.eclipse.scout.rt.client.ui.basic.userfilter.IUserFilterState) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException)

Example 3 with ProcessingException

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());
}
Also used : BlockingCountDownLatch(org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch) Holder(org.eclipse.scout.rt.platform.holders.Holder) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) Test(org.junit.Test)

Example 4 with ProcessingException

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());
    }
}
Also used : BlockingCountDownLatch(org.eclipse.scout.rt.testing.platform.util.BlockingCountDownLatch) Holder(org.eclipse.scout.rt.platform.holders.Holder) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) Test(org.junit.Test)

Example 5 with ProcessingException

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());
    }
}
Also used : IRunnable(org.eclipse.scout.rt.platform.util.concurrent.IRunnable) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) PlatformException(org.eclipse.scout.rt.platform.exception.PlatformException) AssertionException(org.eclipse.scout.rt.platform.util.Assertions.AssertionException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) Test(org.junit.Test)

Aggregations

ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)142 IOException (java.io.IOException)48 MessagingException (javax.mail.MessagingException)21 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)17 File (java.io.File)14 VetoException (org.eclipse.scout.rt.platform.exception.VetoException)12 Folder (javax.mail.Folder)10 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)9 RemoteFile (org.eclipse.scout.rt.shared.services.common.file.RemoteFile)9 NoSuchProviderException (java.security.NoSuchProviderException)8 AssertionException (org.eclipse.scout.rt.platform.util.Assertions.AssertionException)8 FileInputStream (java.io.FileInputStream)7 InputStream (java.io.InputStream)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 FileOutputStream (java.io.FileOutputStream)6 Message (javax.mail.Message)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 OutputStream (java.io.OutputStream)5 HashMap (java.util.HashMap)5