Skip to content

Instantly share code, notes, and snippets.

@hanabokuro
Created June 4, 2015 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanabokuro/6104c09c87e4e4744b4f to your computer and use it in GitHub Desktop.
Save hanabokuro/6104c09c87e4e4744b4f to your computer and use it in GitHub Desktop.
'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