Skip to content
This repository was archived by the owner on Mar 4, 2018. It is now read-only.

Send back a helpful error message object if an error occurs #55

Open
rye opened this issue Feb 18, 2018 · 0 comments
Open

Send back a helpful error message object if an error occurs #55

rye opened this issue Feb 18, 2018 · 0 comments
Assignees
Milestone

Comments

@rye
Copy link
Contributor

rye commented Feb 18, 2018

This would be a useful addition to our flow.

Currently, we do something like:

router.get('/', async (req, res) => {
// check that the user requesting is logged in
if (!req.user) {
res.sendStatus(401) // the user is not logged in
return
}

Note the res.sendStatus(xxx). The docs say that we can chain a .status(code) with a .send(body) to send a custom body along.

I propose something like this as the syntax for our errors:

{
	"errors": [
		{"type": "Unauthorized", "message": "You did not specify a valid token."},
		{"type": "Unauthorized", "message": "Google said you're bad at doing stuff."}
	]
}

Minified, of course.

@rye rye added this to the Version 1 milestone Feb 18, 2018
@rye rye self-assigned this Feb 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant