Skip to content

Instantly share code, notes, and snippets.

@muhammadghazali
Created November 18, 2015 11:20
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 muhammadghazali/b09ef1986014a36a34e8 to your computer and use it in GitHub Desktop.
Save muhammadghazali/b09ef1986014a36a34e8 to your computer and use it in GitHub Desktop.
Something
.findOne({
where: {
id: somethingId
}
})
.then(function(something) {
throw new Error('something not found');
return doSomethingCool();
})
.then(function(resultOfSomethingCool) {
return res.ok(resultOfSomethingCool);
})
.catch(function(err) {
if (err.message === 'something not found') {
return res.notFound({
message: 'Something is not found'
})
}
return res.serverError();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment