Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

don't try catch unexpect call #726

Merged
merged 1 commit into from

4 participants

@JacksonTian

The try/catch will catch exception that from next() call.

@tj tj merged commit 5fb7994 into senchalabs:master
@fengmk2

Good job, this bug is hard to find out.

@JacksonTian JacksonTian deleted the JacksonTian:fix_try_catch branch
@PJmatrix

this remind me of a speech given by @fengmk2

@JacksonTian

Hujs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 12, 2013
  1. @JacksonTian
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/middleware/json.js
View
6 lib/middleware/json.js
@@ -74,13 +74,13 @@ exports = module.exports = function(options){
if (strict && '{' != first && '[' != first) return next(utils.error(400, 'invalid json'));
try {
req.body = JSON.parse(buf, options.reviver);
- next();
} catch (err){
err.body = buf;
err.status = 400;
- next(err);
+ return next(err);
}
+ next();
});
});
- }
+ };
};
Something went wrong with that request. Please try again.