reject = function(reason) {
    return {
      then: function(callback, errback) {
        var result = defer();
        nextTick(function() {
          result.resolve((errback || defaultErrback)(reason));
        });
        return result.promise;
      }
    };
  }
@ngdoc
@name angular.module.ng.$q#reject
@methodOf angular.module.ng.$q
@description
Creates a promise that is resolved as rejected with the specified `reason`. This api should be
used to forward rejection in a chain of promises. If you are dealing with the last promise in
a promise chain, you don't need to worry about it.

When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of
`reject` as the `throw` keyword in JavaScript. This also means that if you "catch" an error via
a promise error callback and you want to forward the error to the promise derived from the
current promise, you have to "rethrow" the error by returning a rejection constructed via
`reject`.

<pre>
  promiseB = promiseA.then(function(result) {
    // success: do something and resolve promiseB
    //          with the old or a new result
    return result;
  }, function(reason) {
    // error: handle the error if possible and
    //        resolve promiseB with newPromiseOrValue,
    //        otherwise forward the rejection to promiseB
    if (canHandle(reason)) {
     // handle the error and recover
     return newPromiseOrValue;
    }
    return $q.reject(reason);
  });
</pre>

@param {*} reason Constant, message, exception or an object representing the rejection reason.
@returns {Promise} Returns a promise that was already resolved as rejected with the `reason`.