Java Code Examples for com.google.inject.ProvisionException#getCause()

The following examples show how to use com.google.inject.ProvisionException#getCause() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Injection.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static <E extends Throwable> E unwrapException(Class<E> type, ProvisionException e) throws E {
    if(e.getCause() instanceof RuntimeException) {
        throw (RuntimeException) e.getCause();
    } else if(type.isInstance(e.getCause())) {
        throw (E) e.getCause();
    } else {
        throw e;
    }
}
 
Example 2
Source File: ApplicationNotReadyTestCase.java    From vespa with Apache License 2.0 5 votes vote down vote up
@Test
public void requireThatExceptionIsThrown() {
    try {
        TestDriver.newInjectedApplicationInstanceWithoutOsgi(MyApplication.class);
        fail();
    } catch (ProvisionException e) {
        Throwable t = e.getCause();
        assertNotNull(t);
        assertTrue(t instanceof ApplicationNotReadyException);
    }
}