Created
February 2, 2012 11:28
-
-
Save yiminghe/1723027 to your computer and use it in GitHub Desktop.
promise using Q about error propagation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var d = Q.defer(), | |
ret = [], | |
p = d.promise; | |
var p2 = p.then( | |
function (v) { | |
ret.push("e1 :" + v); | |
throw "e1"; | |
}, | |
function (r) { | |
ret.push("e2 :" + r); | |
return "e2"; | |
}); | |
var p3 = p2.then( | |
function (v) { | |
ret.push("e3 :" + v); | |
throw "e3"; | |
}, | |
function (r) { | |
ret.push("e4 :" + r); | |
return "e4"; | |
}); | |
var p4 = p3.then(function (v) { | |
ret.push("e5 :" + v); | |
throw "e5"; | |
}, function (r) { | |
ret.push("e6 :" + r); | |
return "e6"; | |
}); | |
setTimeout(function () { | |
d.resolve(1); | |
}, 100); | |
setTimeout(function () { | |
alert(ret.join("\n")); | |
}, 200); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@yiminghe happy to help! :)