Last active
June 2, 2018 05:32
-
-
Save greyscaled/2d69a85b4abd293811f57c83557ef4b6 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
catch (err) { | |
// never forget to rollback | |
await transaction.rollback() | |
if (err instanceof TypeError) { | |
// we know now that we couldn't find a team | |
return res.status(404).send('useful message regarding team not found') | |
} | |
else if (err.message === 'tag not found') { | |
// we know now that we couldn't find one of the tags by supplied id | |
return res.status(404).send('...') | |
} | |
else { | |
// something else happened (such as db connection, model constraints etc.) | |
return next(err) // if you're using error handling middleware | |
// else something like the following: | |
// console.log(err.stack) // we will want to know what | |
// res.status(500).send() // send a 500 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment