How to use the OperationalError function from bluebird
Find comprehensive JavaScript bluebird.OperationalError code examples handpicked from public code repositorys.
37 38 39 40 41 42 43 44 45 46
console.log("testError called"); //Throw an error, the remote Promise will be rejected with a RemoteError, trapped with .catch() //RemoteError.remote contains the remote error object throw new Error("err!"); //or an OperationalError, rejected with a RemoteOperationalError, trapped with .error() //throw new Promise.OperationalError("err!"); } var server = net.createServer(function (c) { remotepromise.instantiate(c, serverfns)
2
0
7
263 264 265 266 267 268 269 270 271 272 273
test('new Promise -> reject -> error', function (t) { t.plan(6) twice(function () { var trans = ins.startTransaction() rejected(new Promise.OperationalError('foo')) .then(function () { t.fail('should not resolve') }).error(function (err) { t.ok(err instanceof Promise.OperationalError)
1
0
1
+ 2 other calls in file
14 15 16 17 18 19 20 21 22 23
var userId = User.getUserIdFromRequest(request) var region = request.payload.region var system = System.findOne().then(function(system) { if (!system.state) { throw new Promise.OperationalError('panic') } return system })
0
0
2
+ 11 other calls in file
GitHub: cameric/8weike-server
0 1 2 3 4 5 6 7 8 9
// This file configures some middlewares for authentication const Promise = require('bluebird'); function requiresLogin(req, res, next) { if (!req.isAuthenticated()) { const error = new Promise.OperationalError('User is not authorized'); return next(Object.assign(error, { status: 401 })); } return next(); }
0
0
5
158 159 160 161 162 163 164 165 166 167
}) } else { return false } }).catch((err) => { // eslint-disable-line handle-callback-err throw new Promise.OperationalError(lang.t('errors:notexist', { path: entryPath })) }) }, /**
0
0
4
bluebird.reject is the most popular function in bluebird (2988 examples)