Skip to content

Instantly share code, notes, and snippets.

View toboid's full-sized avatar

Toby toboid

  • London
  • 06:49 (UTC)
View GitHub Profile
@toboid
toboid / gist:c766cf9e43626f70fe99
Last active August 29, 2015 14:10
Error handing with standard A+ promises
var Promise = require('promise');
// Step 1 fails and rejects it's promise
function step1() {
return new Promise(function(resolve, reject) {
reject('Something went wrong');
});
}
// Step 2 doesn't do anything to handle error
@toboid
toboid / next_handlers.js
Last active August 29, 2015 14:01
Recursively run a set of handlers
var handlers = [];
handlers.push(function(next) {
console.log ('first handler');
next();
});
handlers.push(function(next) {
console.log ('second handler');
next();