Skip to content

Commit

Permalink
Wrap call to hook .initialize() method in try/catch
Browse files Browse the repository at this point in the history
Otherwise errors thrown inside of initialize methods go uncaught.  For example, without this, the error thrown in the "cookieParser" default middleware in lib/hooks/http/middleware/defaults.js crashes the cookieParser middleware test (and not in a good way).
  • Loading branch information
sgress454 committed Feb 10, 2016
1 parent b0a1fb6 commit 3d4a197
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ module.exports = function(sails) {

}, function(err) {
if (err) return cb(err);
self.initialize(cb);
try {
self.initialize(cb);
} catch(e) {
return cb(e);
}
});

};
Expand Down

0 comments on commit 3d4a197

Please sign in to comment.