Skip to content

Instantly share code, notes, and snippets.

@jpina
Created November 25, 2015 11:02
Show Gist options
  • Save jpina/c41248a81b9c0e8e935a to your computer and use it in GitHub Desktop.
Save jpina/c41248a81b9c0e8e935a to your computer and use it in GitHub Desktop.
06 Error Handling
get('story.json').then(function(response) {
console.log("Success!", response);
}, function(error) {
console.log("Failed!", error);
});
/************************************************/
get('story.json').then(function(response) {
console.log("Success!", response);
}).then(undefined, function(error) {
console.log("Failed!", error);
});
/************************************************/
asyncThing1().then(function() {
return asyncThing2();
}).then(function() {
return asyncThing3();
}).catch(function(err) {
return asyncRecovery1();
}).then(function() {
return asyncThing4();
}, function(err) {
return asyncRecovery2();
}).catch(function(err) {
console.log("Don't worry about it");
}).then(function() {
console.log("All done!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment