@Override
 public Promise<V> onFailureBlocking(FailureListener onFailure) {
   addStateListener(
       (promise, state) -> {
         if ((state.isDone() && state == PromiseState.Failed)) {
           try {
             onFailure.onFailure(promise.cause());
           } catch (Throwable e) {
             log.error("Error thrown while calling failure listener", e);
           }
         }
       });
   return this;
 }
  @Override
  public Promise<V> onFailureAsync(FailureListener onFailure) {
    addStateListener(
        (promise, state) -> {
          if (state.isDone() && state == PromiseState.Failed) {
            getFactory()
                .getAsyncExecutor()
                .execute(
                    () -> {
                      try {
                        onFailure.onFailure(promise.cause());
                      } catch (Throwable e) {
                        log.error("Error thrown while calling failure listener", e);
                      }
                    });
          }
        });

    return this;
  }