balderdashy/sails — pull request #329 by particlebanana (2013-04-26 03:54:37+00:00)
Title: Policy Middleware Doesn't Fire Default Error Handler

So if you pass an error to the policy middleware callback the default error handler attached to `sails.express.app.error` never fires due to the way the policy is called in the router.

example policy:

module.exports = function(req, res, next) {
next(new Error('foo bar'));
};

This should fire the default blueprint error but it doesn't. Currently you have to manually send a response back if there is an error.

I have a patch for the router handler function in the policyRouter callback that will make it work but I want to add a test suite. I'll send a pull request in the next day or so after I figure out a good way to test the router.