Loading gulpfile.js +3 −2 Original line number Diff line number Diff line Loading @@ -60,8 +60,9 @@ gulp.task('test', ['clean'], function (done) { gulp.src(paths.specFiles) .pipe(mocha()) .on('error', function () { console.log(chalk.bold.bgRed(' TESTS FAILED ')); .on('error', function (err) { console.error(String(err)); console.error(chalk.bold.bgRed(' TESTS FAILED ')); done(); }) .pipe(istanbul.writeReports({ Loading lib/rp.js +10 −1 Original line number Diff line number Diff line Loading @@ -10,10 +10,15 @@ function ownCallback(err, httpResponse, body) { /* jshint validthis:true */ var self = this; var origCallbackThrewException = false, thrownException; if (_.isFunction(self._rp_callbackOrig)) { try { self._rp_callbackOrig.apply(self, arguments); } catch (e) { } } catch (e) { origCallbackThrewException = true; thrownException = e; } } if (err) { Loading Loading @@ -43,6 +48,10 @@ function ownCallback(err, httpResponse, body) { } } if (origCallbackThrewException) { throw thrownException; } } var originalInit = request.Request.prototype.init; Loading test/request-test.js +24 −11 Original line number Diff line number Diff line Loading @@ -435,21 +435,34 @@ describe('Request-Promise', function () { }); it('and still work if the callback throws an exception', function () { return new Bluebird(function (resolve, reject) { it('and still work if the callback throws an exception', function (done) { var callback = function (err, httpResponse, body) { throw new Error(); }; var originalErrorListeners = process.domain.listeners('error'); process.domain.removeAllListeners('error'); var errorCount = 0; process.domain.on('error', function () { errorCount += 1; }); rp('http://localhost:4000/200', callback) .then(function (body) { process.domain.removeAllListeners('error'); for ( var i = 0; i < originalErrorListeners.length; i+=1 ) { process.domain.on('error', originalErrorListeners[i]); } expect(errorCount).to.eql(1); expect(body).to.eql('GET /200'); resolve(); }); done(); }); }) .catch(done); }); Loading Loading
gulpfile.js +3 −2 Original line number Diff line number Diff line Loading @@ -60,8 +60,9 @@ gulp.task('test', ['clean'], function (done) { gulp.src(paths.specFiles) .pipe(mocha()) .on('error', function () { console.log(chalk.bold.bgRed(' TESTS FAILED ')); .on('error', function (err) { console.error(String(err)); console.error(chalk.bold.bgRed(' TESTS FAILED ')); done(); }) .pipe(istanbul.writeReports({ Loading
lib/rp.js +10 −1 Original line number Diff line number Diff line Loading @@ -10,10 +10,15 @@ function ownCallback(err, httpResponse, body) { /* jshint validthis:true */ var self = this; var origCallbackThrewException = false, thrownException; if (_.isFunction(self._rp_callbackOrig)) { try { self._rp_callbackOrig.apply(self, arguments); } catch (e) { } } catch (e) { origCallbackThrewException = true; thrownException = e; } } if (err) { Loading Loading @@ -43,6 +48,10 @@ function ownCallback(err, httpResponse, body) { } } if (origCallbackThrewException) { throw thrownException; } } var originalInit = request.Request.prototype.init; Loading
test/request-test.js +24 −11 Original line number Diff line number Diff line Loading @@ -435,21 +435,34 @@ describe('Request-Promise', function () { }); it('and still work if the callback throws an exception', function () { return new Bluebird(function (resolve, reject) { it('and still work if the callback throws an exception', function (done) { var callback = function (err, httpResponse, body) { throw new Error(); }; var originalErrorListeners = process.domain.listeners('error'); process.domain.removeAllListeners('error'); var errorCount = 0; process.domain.on('error', function () { errorCount += 1; }); rp('http://localhost:4000/200', callback) .then(function (body) { process.domain.removeAllListeners('error'); for ( var i = 0; i < originalErrorListeners.length; i+=1 ) { process.domain.on('error', originalErrorListeners[i]); } expect(errorCount).to.eql(1); expect(body).to.eql('GET /200'); resolve(); }); done(); }); }) .catch(done); }); Loading