java.lang.reflect.InvocationTargetException

Here are the examples of the java api class java.lang.reflect.InvocationTargetException taken from open source projects.

1. ActionEngine#createException()

Project: paoding-rose
File: ActionEngine.java
private Exception createException(Rose rose, Throwable exception) {
    final RequestPath requestPath = rose.getInvocation().getRequestPath();
    StringBuilder sb = new StringBuilder(1024);
    sb.append("[Rose-").append(RoseVersion.getVersion()).append("@Spring-").append(SpringVersion.getVersion());
    sb.append("]Error happended: ").append(requestPath.getMethod());
    sb.append(" ").append(requestPath.getUri());
    sb.append("->");
    sb.append(this).append(" params=");
    sb.append(Arrays.toString(rose.getInvocation().getMethodParameters()));
    InvocationTargetException servletException = new InvocationTargetException(exception, sb.toString());
    return servletException;
}

2. WebServiceExceptionLoggerTests#testNoStack()

Project: axis2-java
File: WebServiceExceptionLoggerTests.java
/**
     * Validate that if we pass in an exception without any stack information, it does not cause an exception.
     */
public void testNoStack() {
    ServiceClass serviceClass = new ServiceClass();
    Method method = null;
    try {
        method = ImplClass.class.getDeclaredMethod("implMethod");
    } catch (Exception e) {
        e.printStackTrace();
        fail("Test implementation error: unable to get test class method due to exception: " + e.toString());
    }
    Exception rootCause = new EmptyStackTraceException();
    InvocationTargetException invTargetExc = new InvocationTargetException(rootCause);
    WebServiceExceptionLogger.log(method, invTargetExc, false, ImplClass.class, serviceClass, null);
}

3. LazyExceptionTest#neverContainsInvocationTargetException()

Project: totallylazy
File: LazyExceptionTest.java
@Test
public void neverContainsInvocationTargetException() throws Exception {
    final ParseException expected = new ParseException("blah blah", 1);
    final InvocationTargetException invocationTargetException = new InvocationTargetException(expected);
    final LazyException lazyException = lazyException(lazyException(lazyException(invocationTargetException)));
    checkException(lazyException, ParseException.class, expected);
}

4. DeferredProgressMonitorDialogContext#run()

Project: team-explorer-everywhere
File: DeferredProgressMonitorDialogContext.java
@Override
public void run(final boolean fork, final boolean cancelable, final IRunnableWithProgress inputRunnable) throws InvocationTargetException, InterruptedException {
    final RunnableWithProgressWrapper wrappedRunnable = new RunnableWithProgressWrapper(inputRunnable);
    final InvocationTargetException[] invocationTargetExceptionHolder = new InvocationTargetException[1];
    final InterruptedException[] interruptedExceptionHolder = new InterruptedException[1];
    /*
         * Start executing the command in the context of a
         * ProgressMonitorDialog, however do not actually open the progress
         * monitor dialog. The command will execute properly, and we can open
         * the progress monitor dialog after our defer time.
         */
    UIHelpers.runOnUIThread(shell, false, new Runnable() {

        @Override
        public void run() {
            dialog = new ProgressMonitorDialog(shell);
            dialog.setOpenOnRun(false);
            /*
                 * Create a job that will open the progress monitor dialog after
                 * our defer time has elapsed.
                 */
            final Job showProgressUIJob = createProgressUIJob(inputRunnable, wrappedRunnable, dialog);
            showProgressUIJob.setSystem(true);
            showProgressUIJob.schedule(deferTimeMillis);
            BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {

                @Override
                public void run() {
                    setUserInterfaceActive(false);
                    try {
                        /* Run the command. */
                        dialog.run(fork, cancelable, wrappedRunnable);
                    } catch (final InvocationTargetException e) {
                        invocationTargetExceptionHolder[0] = e;
                    } catch (final InterruptedException e) {
                        interruptedExceptionHolder[0] = e;
                    } finally {
                        setUserInterfaceActive(true);
                    }
                }
            });
        }
    });
    if (invocationTargetExceptionHolder[0] != null) {
        throw invocationTargetExceptionHolder[0];
    }
    if (interruptedExceptionHolder[0] != null) {
        throw interruptedExceptionHolder[0];
    }
}

5. ClassReflectionTests#assertNoSuchMethodException()

Project: spring-loaded
File: ClassReflectionTests.java
/**
	 * NoSuchMethodException should be thrown when trying to retrieve a Method object for a non-existent method.
	 */
private void assertNoSuchMethodException(String expectedSignature, ResultException e) {
    InvocationTargetException ite = (InvocationTargetException) e.exception;
    Assert.assertTrue(ite.getCause() instanceof NoSuchMethodException);
    NoSuchMethodException nsme = (NoSuchMethodException) ite.getCause();
    Assert.assertEquals(expectedSignature, nsme.getMessage());
}

6. WorkspaceModifyOperation#run()

Project: che
File: WorkspaceModifyOperation.java
/**
     * The <code>WorkspaceModifyOperation</code> implementation of this
     * <code>IRunnableWithProgress</code> method initiates a batch of changes by
     * invoking the <code>execute</code> method as a workspace runnable
     * (<code>IWorkspaceRunnable</code>).
     */
public final synchronized void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    final InvocationTargetException[] iteHolder = new InvocationTargetException[1];
    try {
        IWorkspaceRunnable workspaceRunnable = new IWorkspaceRunnable() {

            public void run(IProgressMonitor pm) throws CoreException {
                try {
                    execute(pm);
                } catch (InvocationTargetException e) {
                    iteHolder[0] = e;
                } catch (InterruptedException e) {
                    throw new OperationCanceledException(e.getMessage());
                }
            // CoreException and OperationCanceledException are propagated
            }
        };
        ResourcesPlugin.getWorkspace().run(workspaceRunnable, rule, IResource.NONE, monitor);
    } catch (CoreException e) {
        throw new InvocationTargetException(e);
    } catch (OperationCanceledException e) {
        throw new InterruptedException(e.getMessage());
    }
    // Re-throw the InvocationTargetException, if any occurred
    if (iteHolder[0] != null) {
        throw iteHolder[0];
    }
}

7. AbstractAsyncHttpClientFactoryTest#assertException()

Project: async-http-client
File: AbstractAsyncHttpClientFactoryTest.java
private void assertException(AsyncHttpClientImplException e) {
    InvocationTargetException t = (InvocationTargetException) e.getCause();
    Assert.assertTrue(t.getCause() instanceof BadAsyncHttpClientException);
}

8. DB#queryColumn()

Project: Anki-Android
File: DB.java
/**
     * Convenience method for querying the database for an entire column. The column will be returned as an ArrayList of
     * the specified class. See Deck.initUndo() for a usage example.
     *
     * @param type The class of the column's data type. Example: int.class, String.class.
     * @param query The SQL query statement.
     * @param column The column id in the result set to return.
     * @return An ArrayList with the contents of the specified column.
     */
public <T> ArrayList<T> queryColumn(Class<T> type, String query, int column) {
    int nullExceptionCount = 0;
    // to catch the null exception for reporting
    InvocationTargetException nullException = null;
    ArrayList<T> results = new ArrayList<>();
    Cursor cursor = null;
    try {
        cursor = mDatabase.rawQuery(query, null);
        String methodName = getCursorMethodName(type.getSimpleName());
        while (cursor.moveToNext()) {
            try {
                // The magical line. Almost as illegible as python code ;)
                results.add(type.cast(Cursor.class.getMethod(methodName, int.class).invoke(cursor, column)));
            } catch (InvocationTargetException e) {
                if (cursor.isNull(column)) {
                    nullExceptionCount++;
                    if (nullExceptionCount == 1) {
                        nullException = e;
                        Toast.makeText(AnkiDroidApp.getInstance().getBaseContext(), "Error report pending: unexpected null in database.", Toast.LENGTH_LONG).show();
                    }
                } else {
                    throw new RuntimeException(e);
                }
            }
        }
    } catch (NoSuchMethodExceptionIllegalAccessException | IllegalArgumentException |  e) {
        throw new RuntimeException(e);
    } finally {
        if (cursor != null) {
            cursor.close();
        }
        if (nullExceptionCount > 0) {
            if (nullException != null) {
                StringBuilder sb = new StringBuilder();
                sb.append("DB.queryColumn (column " + column + "): ");
                sb.append("Exception due to null. Query: " + query);
                sb.append(" Null occurrences during this query: " + nullExceptionCount);
                AnkiDroidApp.sendExceptionReport(nullException, "queryColumn_encounteredNull", sb.toString());
                Timber.w(sb.toString());
            } else {
                // nullException not properly initialized
                StringBuilder sb = new StringBuilder();
                sb.append("DB.queryColumn(): Critical error -- ");
                sb.append("unable to pass in the actual exception to error reporting.");
                AnkiDroidApp.sendExceptionReport(new RuntimeException("queryColumn null"), "queryColumn_encounteredNull", sb.toString());
                Timber.e(sb.toString());
            }
        }
    }
    return results;
}