@Override public Object waitForCompletion(FlowId flowId, CompletionId completionId, ClassLoader loader) { return withActiveGraph(flowId, (flow) -> flow.withStage(completionId, (stage) -> { try { return stage.outputFuture().toCompletableFuture().get().toJava(flowId, this, loader); } catch (ExecutionException e) { if (e.getCause() instanceof ResultException) { APIModel.CompletionResult r = ((ResultException) e.getCause()).toResult(); Object err = r.toJava(flowId, this, loader); if (err instanceof Throwable) { throw new FlowCompletionException((Throwable) err); } else if (err instanceof HttpResponse && !r.successful) { throw new FlowCompletionException(new FunctionInvocationException((HttpResponse) err)); } throw new PlatformException(e); } else { throw new PlatformException(e); } } catch (Exception e) { throw new PlatformException(e); } })); }
Object err = r.toJava(flowId, this, loader); if (err instanceof Throwable) { throw new FlowCompletionException((Throwable) err); } else if (err instanceof HttpResponse && !r.successful) { throw new FlowCompletionException(new FunctionInvocationException((HttpResponse) err));
return resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()); } else { throw new FlowCompletionException((Throwable) resp.result.toJava(flowId, blobStoreClient, getClass().getClassLoader()));