code: function (fulfilled, rejected) {
              var self = this, onUnhandledError = function (e) {
                      LoggerManager.log(e.stack || e, 'error');
                      setTimeout(function () {
                          throw e;
                      }, 0);
                  }, promiseToHandle = fulfilled || rejected ? self.then(fulfilled, rejected) : self;
              promiseToHandle.fail(onUnhandledError);
          }
docs: register callbacks when this promise object is resolved,
  and throw error at next event loop if promise
  (current instance if no fulfilled and rejected parameter or
  new instance caused by call this.then(fulfilled, rejected))
  fails.
  @param {Function} [fulfilled] called when resolved successfully,pass a resolved value to this function and
  return a value (could be promise object) for the new promise 's resolved value.
  @param {Function} [rejected] called when error occurs,pass error reason to this function and
  return a new reason for the new promise 's error reason