Created
November 18, 2015 11:20
-
-
Save muhammadghazali/b09ef1986014a36a34e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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