private static void logIfNeeded(Throwable e, boolean wrapIntoThrowable, Consumer<Throwable> action) {
    if (e instanceof VMDisconnectedException || e instanceof ProcessCanceledException) {
      throw (RuntimeException)e;
    }
    action.accept(wrapIntoThrowable ? new Throwable(e) : e);
  }
private static void logIfNeeded(Throwable e, boolean wrapIntoThrowable, Consumer<Throwable> action)