Skip to content

Instantly share code, notes, and snippets.

@deepal
Last active September 25, 2019 15:20
Show Gist options
  • Select an option

  • Save deepal/cf61bc4972a77566d7637f800ed29a78 to your computer and use it in GitHub Desktop.

Select an option

Save deepal/cf61bc4972a77566d7637f800ed29a78 to your computer and use it in GitHub Desktop.
if (err instanceof AuthenticationError) {
return res.status(401).send('not authenticated');
}
if (err instanceof UnauthorizedError) {
return res.status(403).send('forbidden');
}
if (err instanceof InvalidInputError) {
return res.status(400).send('bad request');
}
if (err instanceof DuplicateKeyError) {
return res.status(409).send('conflict. entity already exists');
}
// Generic error
return res.status(500).send('internal error occurred')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment