code: @Override
      public <OUT> IPromise<OUT> catchError(final Function<Object, IPromise<OUT>> function) {
          Promise res = new Promise<>();
          then( new Callback<T>() {
              @Override
              public void complete(T result, Object error) {
                  if ( ! Actor.isError(error) ) {
                      res.complete(null, error);
                  } else {
                      function.apply(error).then(res);
                  }
              }
          });
          return res;
      }
docs: see IPromise (inheriting Callback) interface