I am coding using co module on sail framework.
I want to catch InvalidError but error log says 'undefined'.
How can I fix this code?
Co module can't catch ErrorType specification??
detail: function (req, res) {
co(function *() {
let errors = [];
const text = req.param('text');
if (text.length <= 0) {
throw new InvalidError('text is required');
}
}).catch((InvalidError, err) => {
sails.log.warn(err);
errors.push(err.message);
req.flash('errors', errors);
res.redirect('/somewhere/view');
}).catch((Error, err) => {
sails.log.error(err);
res.serverError(err);
});
}
error log is here
warn: undefined
error: undefined
error: Sending empty 500 ("Server Error") response