Created
June 4, 2015 03:08
-
-
Save hanabokuro/6104c09c87e4e4744b4f to your computer and use it in GitHub Desktop.
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
'use strcit' | |
var Promise = require('bluebird'); | |
function findUser(id) { | |
// return Promise.resolve({id: id}) | |
return Promise.reject('not found') | |
} | |
var user = findUser(12) | |
user.catch(function(e){ console.log('catch1-1:' + e)}).catch(function(e){ console.log('catch1-2:' + e)}) | |
user.then(function(u){ console.log('u:'+u)}).catch(function(e){console.log('catch2-1:'+e)}).catch(function(e){console.log('catch2-2:'+e)}) | |
/* | |
catch1-1:not found | |
catch2-1:not found | |
と両方でキャッチされる | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment