public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { Xpaths = doScan( monitor ); } catch ( Exception e ) { e.printStackTrace(); throw new InvocationTargetException( e, BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Exception.ErrorScanningFile", filename, e.toString() ) ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { fields = doScan( monitor ); } catch ( Exception e ) { e.printStackTrace(); throw new InvocationTargetException( e, BaseMessages.getString( PKG, "GetXMLDateLoopNodesImportProgressDialog.Exception.ErrorScanningFile", filename, e.toString() ) ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { message = doScan( monitor, failOnParseError ); } catch ( Exception e ) { e.printStackTrace(); throw new InvocationTargetException( e, BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Exception.ErrorScanningFile", "" + rownumber, debug, e.toString() ) ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { message = doScan( monitor, failOnParseError ); } catch ( Exception e ) { e.printStackTrace(); throw new InvocationTargetException( e, BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Exception.ErrorScanningFile", "" + rownumber, debug, e.toString() ) ); } } };
public Object invoke (Object target, Object[] args) throws IllegalAccessException, InvocationTargetException { try { return methodAccess.invoke(target, methodAccessIndex, args); } catch (Exception ex) { throw new InvocationTargetException(ex); } } }
protected static Throwable exceptionFromStream(DataInput in, int recursion_count) throws Exception { // 1. null check if(in.readBoolean()) return null; // 2. InvocationTargetException if(in.readBoolean()) return new InvocationTargetException(readException(in, recursion_count)); return readException(in, recursion_count); }
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { db = new Database( Spoon.loggingObject, dbMeta ); try { db.connect(); result = db.getQueryFields( sql, false ); if ( monitor.isCanceled() ) { throw new InvocationTargetException( new Exception( "This operation was cancelled!" ) ); } } catch ( Exception e ) { throw new InvocationTargetException( e, "Problem encountered determining query fields: " + e.toString() ); } finally { db.disconnect(); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { rep.save( jobMeta, versionComment, new ProgressMonitorAdapter( monitor ) ); } catch ( KettleException e ) { throw new InvocationTargetException( e, "Error saving job" ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { impact.clear(); // Start with a clean slate!! transMeta.analyseImpact( impact, new ProgressMonitorAdapter( monitor ) ); impactHasRun = true; } catch ( Exception e ) { impact.clear(); impactHasRun = false; // Problem encountered generating impact list: {0} throw new InvocationTargetException( e, BaseMessages.getString( PKG, "AnalyseImpactProgressDialog.RuntimeError.UnableToAnalyzeImpact.Exception", e.toString() ) ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { transMeta.checkSteps( remarks, onlySelected, new ProgressMonitorAdapter( monitor ), space, repository, metaStore ); } catch ( Exception e ) { throw new InvocationTargetException( e, BaseMessages.getString( PKG, "AnalyseImpactProgressDialog.RuntimeError.ErrorCheckingTransformation.Exception", e.toString() ) ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { dmi.getData( Spoon.loggingObject, new ProgressMonitorAdapter( monitor ) ); } catch ( Exception e ) { throw new InvocationTargetException( e, BaseMessages.getString( PKG, "GetDatabaseInfoProgressDialog.Error.GettingInfoTable", e.toString() ) ); } } };
private static <T> void callAllPublicMethods(TypeToken<T> type, T object) throws InvocationTargetException { for (Method method : type.getRawType().getMethods()) { if ((method.getModifiers() & STATIC) != 0) { continue; } ImmutableList<Parameter> parameters = type.method(method).getParameters(); Object[] args = new Object[parameters.size()]; for (int i = 0; i < parameters.size(); i++) { args[i] = getDefaultValue(parameters.get(i).getType()); } try { try { method.invoke(object, args); } catch (InvocationTargetException ex) { try { throw ex.getCause(); } catch (UnsupportedOperationException unsupported) { // this is a legit exception } } } catch (Throwable cause) { throw new InvocationTargetException( cause, method + " with args: " + Arrays.toString(args)); } } } }
private InvocationTargetException givenAnInvocationExceptionWrappingAnErrorNotHandledException() { ErrorNotHandledException errorNotHandledException = new ErrorNotHandledException(error); return new InvocationTargetException(errorNotHandledException); }
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { // This is running in a new process: copy some KettleVariables info // LocalVariables.getInstance().createKettleVariables(Thread.currentThread(), parentThread, true); // --> don't set variables if not running in different thread --> pmd.run(true,true, op); try { stats = transMeta.getSQLStatements( new ProgressMonitorAdapter( monitor ) ); } catch ( KettleException e ) { throw new InvocationTargetException( e, BaseMessages.getString( PKG, "GetSQLProgressDialog.RuntimeError.UnableToGenerateSQL.Exception", e.getMessage() ) ); } } };
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { try { rep.save( meta, versionComment, new ProgressMonitorAdapter( monitor ) ); } catch ( KettleException e ) { throw new InvocationTargetException( e, BaseMessages.getString( PKG, "TransSaveProgressDialog.Exception.ErrorSavingTransformation" ) + e.toString() ); } } };
@Test public void convertReflectionExceptionToUnchecked() { IllegalArgumentException iae = new IllegalArgumentException(); // ReflectionException,normal RuntimeException e = ReflectionUtil.convertReflectionExceptionToUnchecked(iae); assertThat(e).isEqualTo(iae); // InvocationTargetException,extract it's target exception. Exception ex = new Exception(); e = ReflectionUtil.convertReflectionExceptionToUnchecked(new InvocationTargetException(ex)); assertThat(e.getCause()).isEqualTo(ex); // UncheckedException, ignore it. RuntimeException re = new RuntimeException("abc"); e = ReflectionUtil.convertReflectionExceptionToUnchecked(re); assertThat(e).hasMessage("abc"); // Unexcepted Checked exception. e = ReflectionUtil.convertReflectionExceptionToUnchecked(ex); assertThat(e).isInstanceOf(UncheckedException.class); }
@Test public void unwrap() { RuntimeException re = new RuntimeException("my runtime"); assertThat(ExceptionUtil.unwrap(re)).isSameAs(re); ExecutionException ee = new ExecutionException(re); assertThat(ExceptionUtil.unwrap(ee)).isSameAs(re); InvocationTargetException ie = new InvocationTargetException(re); assertThat(ExceptionUtil.unwrap(ie)).isSameAs(re); Exception e = new Exception("my exception"); ExecutionException ee2 = new ExecutionException(e); try{ ExceptionUtil.unwrapAndUnchecked(ee2); }catch (Throwable t) { assertThat(t).isInstanceOf(UncheckedException.class).hasCauseExactlyInstanceOf(Exception.class); } }
@Test public void invocationTargetExceptionIsUnwrapped() { Throwable cause = new WhateverException(); InvocationTargetException ite = new InvocationTargetException(cause); assertThatThrownBy(() -> Sneaky.throwAnyway(ite)) .isSameAs(cause); }
@Test public void testWrappedMetaExceptionRetry() throws MetaException { IHMSHandler mockBaseHandler = Mockito.mock(IHMSHandler.class); Mockito.when(mockBaseHandler.getConf()).thenReturn(conf); //JDOException wrapped in MetaException wrapped in InvocationException MetaException me = new MetaException("Dummy exception"); me.initCause(new JDOException()); InvocationTargetException ex = new InvocationTargetException(me); Mockito .doThrow(me) .doNothing() .when(mockBaseHandler).init(); RetryingHMSHandler.getProxy(conf, mockBaseHandler, false); Mockito.verify(mockBaseHandler, Mockito.times(2)).init(); } }
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException { db = new Database( Spoon.loggingObject, dbMeta ); try { db.connect(); if ( limit > 0 ) { db.setQueryLimit( limit ); } rows = db.getFirstRows( tableName, limit, new ProgressMonitorAdapter( monitor ) ); rowMeta = db.getReturnRowMeta(); } catch ( KettleException e ) { throw new InvocationTargetException( e, "Couldn't find any rows because of an error :" + e.toString() ); } finally { db.disconnect(); } } };