@Override public boolean matches(Object item) { if (!(item instanceof UserCodeException)) { return false; } UserCodeException that = (UserCodeException) item; return causeMatcher.matches(that.getCause()); }
private static RuntimeException beamExceptionFrom(final Throwable e) { // Scala doesn't declare checked exceptions in the bytecode, and the Java compiler // won't let you catch something that is not declared, so we can't catch // SparkException directly, instead we do an instanceof check. if (e instanceof SparkException) { if (e.getCause() != null && e.getCause() instanceof UserCodeException) { UserCodeException userException = (UserCodeException) e.getCause(); return new Pipeline.PipelineExecutionException(userException.getCause()); } else if (e.getCause() != null) { return new Pipeline.PipelineExecutionException(e.getCause()); } } return runtimeExceptionFrom(e); }
@Override public PipelineResult run(Pipeline pipeline) { try { return delegate.run(pipeline); } catch (Throwable t) { // Special case hack to pull out assertion errors from PAssert; instead there should // probably be a better story along the lines of UserCodeException. UserCodeException innermostUserCodeException = null; Throwable current = t; for (; current.getCause() != null; current = current.getCause()) { if (current instanceof UserCodeException) { innermostUserCodeException = (UserCodeException) current; } } if (innermostUserCodeException != null) { current = innermostUserCodeException.getCause(); } if (current instanceof AssertionError) { throw (AssertionError) current; } throw new PipelineExecutionException(current); } }
@Override public PipelineResult run(Pipeline pipeline) { try { return delegate.run(pipeline); } catch (Throwable t) { // Special case hack to pull out assertion errors from PAssert; instead there should // probably be a better story along the lines of UserCodeException. UserCodeException innermostUserCodeException = null; Throwable current = t; for (; current.getCause() != null; current = current.getCause()) { if (current instanceof UserCodeException) { innermostUserCodeException = ((UserCodeException) current); } } if (innermostUserCodeException != null) { current = innermostUserCodeException.getCause(); } if (current instanceof AssertionError) { throw (AssertionError) current; } throw new PipelineExecutionException(current); } }
@Override public PipelineResult run(Pipeline pipeline) { try { return delegate.run(pipeline); } catch (Throwable t) { // Special case hack to pull out assertion errors from PAssert; instead there should // probably be a better story along the lines of UserCodeException. UserCodeException innermostUserCodeException = null; Throwable current = t; for (; current.getCause() != null; current = current.getCause()) { if (current instanceof UserCodeException) { innermostUserCodeException = (UserCodeException) current; } } if (innermostUserCodeException != null) { current = innermostUserCodeException.getCause(); } if (current instanceof AssertionError) { throw (AssertionError) current; } throw new PipelineExecutionException(current); } }
throw new Pipeline.PipelineExecutionException(uce.getCause()); } catch (Exception e) { if (e instanceof InterruptedException) {
/** * Runs this {@link Pipeline} using the given {@link PipelineOptions}, using the runner specified * by the options. */ public PipelineResult run(PipelineOptions options) { PipelineRunner<? extends PipelineResult> runner = PipelineRunner.fromOptions(options); // Ensure all of the nodes are fully specified before a PipelineRunner gets access to the // pipeline. LOG.debug("Running {} via {}", this, runner); try { validate(options); return runner.run(this); } catch (UserCodeException e) { // This serves to replace the stack with one that ends here and // is caused by the caught UserCodeException, thereby splicing // out all the stack frames in between the PipelineRunner itself // and where the worker calls into the user's code. throw new PipelineExecutionException(e.getCause()); } }
result.waitUntilFinish(); } catch (UserCodeException userException) { throw new PipelineExecutionException(userException.getCause()); } catch (Throwable t) { if (t instanceof RuntimeException) {