Skip to content

Instantly share code, notes, and snippets.

@gx0r
Created July 18, 2014 19:32
Show Gist options
  • Save gx0r/1f95ad761e1bb5d1c9cb to your computer and use it in GitHub Desktop.
Save gx0r/1f95ad761e1bb5d1c9cb to your computer and use it in GitHub Desktop.
var Promise = require('bluebird');
Promise.longStackTraces();
//var Promise = require('q');
Promise.reject('first thingy')
.then(function (a) {
console.log('then 1 ' + a);
})
.finally(function (x) {
console.log('finally 1');
throw 'finally err'
})
.catch(function (c) {
console.log('catch 1 '+c)
})
.then(function () {
console.log('then 2')
})
.catch(function (c) {
console.log('catch 2 '+c)
})
.finally(function (x) {
console.log('finally 2');
})
.then(function () {
console.log('then 3')
})
.catch(function (c) {
console.log('catch 3 '+c)
})
.finally(function (x) {
console.log('finally 3');
})
.catch(function (x) {
console.log('catch 4');
})
.then(function () {
console.log('then 4')
})
.then(function () {
throw 'hi';
})
.finally(function () {
console.log('finally 4 ');
})
.finally(function () {
console.log('finally 5');
// throw 'finally 5';
})
/*
.catch(function (x) {
console.log('catch 5 ' + x);
})
*/
/*
.then(function () {
console.log('then 1');
});
*/
/*
Promise.all([Promise.reject("one")]).catch(
function (err) {
console.log('Logging error: ' + err);
}
);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment