Calling emitError will indicate that the promise failed

@param {*} value send to all resolved callbacks
@return this
168251
function (error, dontThrow) {
        var self = this;

        self.isError = true;
        self._notifyAll(error);
        if (!dontThrow) {
            enqueue(function () {
                if (!self.handled) {
                    throw error;
                }
            });
        }
        return self.handled;
    }
352569
function (cb) {
            if (cb) {
                if (isPromise(cb)) {
                    cb = cb.callback;
                }
                if (this.__fired && this.__results) {
                    this.__callNextTick(cb, this.__results);
                } else {
                    this.__cbs.push(cb);
                }
            }
            return this;
        }
328146
function notifyAll(newState, newValue) {
    if (newState === webdriver.promise.Deferred.State_.REJECTED &&
        // We cannot check instanceof Error since the object may have been
        // created in a different JS context.
        goog.isObject(newValue) && goog.isString(newValue.message)) {
      newValue = flow.annotateError(/** @type {!Error} */(newValue));
    }

    state = newState;
    value = newValue;
    while (listeners.length) {
      notify(listeners.shift());
    }

    if (!handled && state == webdriver.promise.Deferred.State_.REJECTED) {
      pendingRejectionKey = propagateError(value);
    }
  }
140385
function (value) {
            var promise = this.promise, pendings;
            if ((pendings = promise[PROMISE_PENDINGS]) === false) {
                return null;
            }    // set current promise 's resolved value
                 // maybe a promise or instant value
            // set current promise 's resolved value
            // maybe a promise or instant value
            promise[PROMISE_VALUE] = value;
            pendings = pendings ? [].concat(pendings) : [];
            promise[PROMISE_PENDINGS] = false;
            promise[PROMISE_PROGRESS_LISTENERS] = false;
            util.each(pendings, function (p) {
                promiseWhen(promise, p[0], p[1]);
            });
            return value;
        }
544055
function promise (input, value) {
  value.then(val => {
    morph(val, input)
  }, reason => {
    input.emit('error', reason)
  })
}
1192399
function(value)
				{
					if(this.state !== STATE_PENDING)
						return;

					if(value === this)
						return this.reject(new TypeError("Attempt to resolve promise with self"));

					var me = this; // preserve this

					if(value && (typeof value === "function" || typeof value === "object"))
					{
						try
						{
							var first = true; // first time through?
							var then = value.then;
							if(typeof then === "function")
							{
								// and call the value.then (which is now in "then") with value as the context and the resolve/reject functions per thenable spec
								then.call(value,
									function(ra) { if(first) { first=false; me.resolve(ra);}  },
									function(rr) { if(first) { first=false; me.reject(rr); } });
								return;
							}
						}
						catch(e)
						{
							if(first)
								this.reject(e);
							return;
						}
					}

					this.state = STATE_FULFILLED;
					this.v = value;

					if(me.c)
						soon(function() {
								for(var n=0, l=me.c.length;n<l;n++)
									resolveClient(me.c[n],value);
							});
				}
696880
function _fulfilled(value) {
            try {
                return fulfilled ? fulfilled.call(this, value) : // propagate
                value;
            } catch (e) {
                // can not use logger.error
                // must expose to user
                // print stack info for firefox/chrome
                logError(e.stack || e);
                return new Reject(e);
            }
        }
126931
function _runError(error, module) {
  const _error = new emitter.Error({
    target:module.filename,
    source:(module.parent || module).filename,
    error
  });
  module.exports = _error;
  emitter.emit('error', _error);
  return (!!_error.ignore || (_error.ignore && isFunction(_error.ignore) && _error.ignore()));
}
413423
def fulfill(self, value):
        

        assert self._state==self.PENDING

        self._state=self.FULFILLED;
        self.value = value
        for callback in self._callbacks:
            try:
                callback(value)
            except Exception:
                # Ignore errors in callbacks
                pass
        # We will never call these callbacks again, so allow
        # them to be garbage collected.  This is important since
        # they probably include closures which are binding variables
        # that might otherwise be garbage collected.
        self._callbacks = []
934535
function output (err, value) {
      // Buffer err and value for
      // sending in case we do not have
      // a callback yet
      if (arguments.length >= 1) {
        buffer.push([err, value])
      }

      // We have something to output
      // and a callback, do it
      if (_cb && buffer.length > 0) {
        var cb = _cb
        _cb = null
        var call = buffer.shift()
        cb(call[0], call[1])
      }
    }
1009928
function then(resolver, onFulfilled, onRejected) {
        var res = new Resolver();
        var promise = createPromise(res);

        if (isFunction(onFulfilled)) {
            onFulfilled = wrapCallback(res, promise, onFulfilled);
        }
        else {
            // not function
            // 'return promise' must fulfill with the same value
            // when 'main promise' is resolved
            // see #2.2.7.3
            onFulfilled = function (data) {
                res.fulfill(data);
            };
        }
        addListener(resolver, STATUS.FULFILLED, onFulfilled);

        if (isFunction(onRejected)) {
            onRejected = wrapCallback(res, promise, onRejected);
        }
        else {
            // not function
            // 'return promise' must reject with the same reason
            // when 'main promise' is rejected
            // see #2.2.7.4
            onRejected = function (reason) {
                res.reject(reason);
            };
        }
        addListener(resolver, STATUS.REJECTED, onRejected);

        return promise;
    }
1096790
function promiseOrCallback (callback, executor) {
    var promise = new Promise(executor);

    // no callback: do not attach
    if (typeof callback !== 'function') {
        return promise;
    }

    return promise.then(function (value) {
        setImmediate(function () {
            callback(null, value);
        });
        return value;
    }, function (error) {
        setImmediate(function () {
            callback(error);
        });
        throw error;
    });
}
280565
@ObjectiveCName("failure:")
    public synchronized Promise<T> failure(final Consumer<Exception> failure) {
        if (isFinished) {
            if (exception != null) {
                dispatcher.dispatch(() -> failure.apply(exception));
            }
        } else {

            callbacks.add(new PromiseCallback<T>() {
                @Override
                public void onResult(T t) {
                    // Do nothing
                }

                @Override
                public void onError(Exception e) {
                    failure.apply(e);
                }
            });
        }
        return this;
    }
361065
function TrojanHorsePromise(callback) {
  var
    $callback = Object,
    $errback = Object
  ;
  function resolve(result) { $callback(result); }
  function reject(error) { $errback(error); }
  setTimeout(callback, 0, resolve, reject);
  return {
    then: function (callback, errback) {
      $callback = callback;
      if (errback) this.catch(errback);
    },
    catch: function (errback) {
      $errback = errback;
    }
  };
}
72557
function fulfillPromise(promise, value) {
  if (promise.state !== PENDING) {return;}

  setValue(promise, value);
  setState(promise, UNFULFILLED);

  setImmediate(function() {
    setState(promise, FULFILLED);
    invokeFunctions(promise);
  });
}
613334
function (error) {
            this.error = error;
            this.isRejected = true;

            if (this.parent === null) {
                return;
            }

            this.parent.dispatch(this.name);
            this.parent.dispatch('reject', {
                data : { node : this, error: error }
            });
        }
1338394
function createInvalidExceptionError(message, value) {
  var err = new Error(message);
  err.code = 'ERR_MOCHA_INVALID_EXCEPTION';
  err.valueType = typeof value;
  err.value = value;
  return err;
}