throw Error after promise is rejected - Q
问题 following is a short example for using a promise with Q. this is test1.js: function testDefer() { var deferred = Q.defer(); fs.readFile("foo.txt", "utf-8", function (error, text) { if (error) { deferred.reject(new Error(error)); } else { deferred.resolve(text); } }); return deferred.promise; } and this is test2.js (function(){ 'use strict'; var test1 = require('./test1'); test1.testDefer().then( function(data){ console.log('all good'); }, function(err) { //upon error i might want to throw an