How to use the bluebird.reject function in bluebird

To help you get started, we’ve selected a few bluebird examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github untu / comedy / lib / forked-actor.js View on Github external
_decodeMessageBody(body, handle) {
    if (handle) {
      switch (body.message.handleType) {
        case 'net.Server':
          return P.resolve([handle]);

        case 'http.Server': {
          // Wrap net.Server into http.Server.
          let ret = http.createServer();
          ret.listen(handle);

          return P.resolve([ret]);
        }

        default:
          return P.reject(new Error('Unknown handle type: ' + body.message.handleType));
      }
    }

    let message = body.message;
    let marshalledTypes = body.marshalledType;

    if (!message) {
      message = [];
      marshalledTypes = [];
    }

    if (!_.isArray(message)) {
      message = [message];
      marshalledTypes = [marshalledTypes];
    }
github serverless / serverless / lib / actions / ComponentCreate.js View on Github external
}
      }

      // Add default runtime
      if (!this.evt.options.runtime) {
        this.evt.options.runtime = 'nodejs';
      }

      // Check runtime
      if (!this.S.classes.Component.getSupportedRuntimes()[this.evt.options.runtime]) {
        return BbPromise.reject(new SError('Unsupported runtime ' + this.evt.options.runtime, SError.errorCodes.UNKNOWN));
      }

      // Check is not reserved name
      if (['meta', '_meta', 'plugins'].indexOf(this.evt.options.name) != -1) {
        return BbPromise.reject(new SError('This component name is reserved: ' + this.evt.options.name, SError.errorCodes.UNKNOWN));
      }

      // If component exists in project, throw error
      if (this.S.getProject().validateComponentExists(this.evt.options.name, this.S._projectPath)) {
        return BbPromise.reject(new SError(
          'Component ' + this.evt.options.name + ' already exists',
          SError.errorCodes.INVALID_PROJECT_SERVERLESS
        ));
      }

      return BbPromise.resolve();
    };
github flywheelsports / hydra / index.js View on Github external
    this.ready = () => Promise.reject(new Error('You must call hydra.init() before invoking hydra.ready()'));
  }
github TradeMe / tractor / packages / tractor / server / utils / file-structure-modifier.spec.js View on Github external
it('should handle any errors that occur:', function () {
        var logging = require('./logging');
        var response = {
            send: _.noop,
            status: _.noop
        };

        sinon.stub(logging, 'error');
        sinon.stub(fileStructureUtilsMock, 'getFileStructure').returns(Promise.reject(new Error()));
        sinon.spy(response, 'send');
        sinon.spy(response, 'status');

        return fileStructureModifier.create()(null, response)
        .then(function () {
            expect(fileStructureUtilsMock.getFileStructure.callCount).to.equal(1);
            expect(response.status).to.have.been.calledWith(500);
            expect(response.send).to.have.been.calledWith('{"error":"Operation failed."}');
        })
        .finally(function () {
            fileStructureUtilsMock.getFileStructure.restore();
            logging.error.restore();
        });
    });
github broidHQ / integrations / broid-telegram / lib / core / Adapter.js View on Github external
channels() {
        return Promise.reject(new Error('Not supported'));
    }
    serviceId() {
github ZZROTDesign / alpine-ghost / ghost / core / server / data / validation / index.js View on Github external
validateSettings = function validateSettings(defaultSettings, model) {
    var values = model.toJSON(),
        validationErrors = [],
        matchingDefault = defaultSettings[values.key];

    if (matchingDefault && matchingDefault.validations) {
        validationErrors = validationErrors.concat(validate(values.value, values.key, matchingDefault.validations));
    }

    if (validationErrors.length !== 0) {
        return Promise.reject(validationErrors);
    }

    return Promise.resolve();
};
github MarkBind / markbind / src / Site.js View on Github external
    .catch(() => Promise.reject(new Error(`Failed to copy over ${filePath}`)));
};
github fabienvauchelles / qscore / platform-engine / src / model / leads / leads.controller.js View on Github external
getPlayerRank(competitionId, playerSub) {
        if (!competitionId ||
            competitionId.length <= 0) {
            return Promise.reject(new WrongParameterError('competitionId'));
        }

        if (!playerSub ||
            playerSub.length <= 0) {
            return Promise.reject(new WrongParameterError('playerSub'));
        }

        winston.debug('[LeadsController] getPlayerRank(): competitionId=', competitionId, ' / playerSub=', playerSub);

        return Promise
            .all([
                getRank(competitionId, playerSub),
                competitionsController.getPlayersCount(competitionId),
            ])
            .spread((rank, total) => ({rank, total}))
        ;


        ////////////

        function getRank(cId, pSub) {
github felixrieseberg / Ghost-Azure / core / server / api / users.js View on Github external
return dataProvider.User.findOne({role: 'Owner'}).then(function (owner) {
                        if (contextUser.id !== owner.id) {
                            if (editedUserId === owner.id) {
                                if (owner.related('roles').at(0).id !== roleId) {
                                    return Promise.reject(new errors.NoPermissionError('Cannot change Owner\'s role.'));
                                }
                            } else if (roleId !== contextRoleId) {
                                return canThis(options.context).assign.role(role).then(function () {
                                    return options;
                                });
                            }
                        }

                        return options;
                    });
                });
github wise-team / steem-wise-core / src / api / WiseRESTApi.ts View on Github external
public getWiseOperationsRelatedToDelegatorInBlock(delegator: string, blockNum: number): Promise {
        return BluebirdPromise.reject(new Error("Not implemented yet"));
    }