private static @NotNull FinishBuildEvent getSyncFinishEvent(
    @NotNull ExternalSystemTaskId taskId,
    @NotNull Ref<? extends Supplier<? extends FinishBuildEvent>> finishSyncEventSupplier
  ) {
    Exception exception = null;
    var finishBuildEventSupplier = finishSyncEventSupplier.get();
    if (finishBuildEventSupplier != null) {
      try {
        return finishBuildEventSupplier.get();
      }
      catch (Exception e) {
        exception = e;
      }
    }
    if (!(exception instanceof ControlFlowException)) {
      LOG.warn("Sync finish event has not been received", exception);
    }
    var eventTime = System.currentTimeMillis();
    var eventMessage = BuildBundle.message("build.status.cancelled");
    var eventResult = new FailureResultImpl();
    return new FinishBuildEventImpl(taskId, null, eventTime, eventMessage, eventResult);
  }
private static @NotNull FinishBuildEvent getSyncFinishEvent(
    @NotNull ExternalSystemTaskId taskId,
    @NotNull Ref<? extends Supplier<? extends FinishBuildEvent>> finishSyncEventSupplier
  )