Skip to content

Loading…

Actually bail if db not present. Fixes #4. #6

Closed
wants to merge 1 commit into from

3 participants

@6a68
Mozilla member

@jedp or @seanmonstar, mind having a look?

Hmm. arguably if the DB is gone we should return a 500 every time?

Ah well. This preserves current behavior, minus one bug I found (#4) and another I didn't (when you try to DELETE a user programmatically and the DB is gone, same badness).

res.json/res.send means res is done, but the function continues, does db.foo() where db is null, and, f7u12.

@seanmonstar
Mozilla member

yea, strange that we'd return a 200 if the db is gone. that sounds like a 500 to me.

@jedp

I'm with @seanmonstar on returning a 500. Possibly even a res.json(500, {"error":"dude, where's your database?"})

@6a68
Mozilla member

thanks for the feedback, yall.

@6a68 6a68 closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 9, 2013
  1. @6a68
Showing with 2 additions and 2 deletions.
  1. +2 −2 webserver.js
View
4 webserver.js
@@ -32,7 +32,7 @@ function canonicalize(email) {
// the 'todo/get' api gets the current version of the todo list
// from the server
app.get('/mail/:user', function(req, res) {
- if (!db) res.json([]);
+ if (!db) return res.json([]);
req.params.user = canonicalize(req.params.user);
@@ -53,7 +53,7 @@ app.get('/mail/:user', function(req, res) {
});
app.delete('/mail/:user', function(req, res) {
- if (!db) res.send(200);
+ if (!db) return res.send(200);
req.params.user = canonicalize(req.params.user);
Something went wrong with that request. Please try again.