I have the following situation, i have a middleware that add a flag when a user is logging
//if some situation happend
req.feathers.isAuthenticated = true;
//else
req.feathers.isAuthenticated = false;
next();
and i have a hook that check if a user is already logged in some services
myService.before({
create(hook, next) {
if (!hook.params.isAuthenticated) {
throw new Error('AccessDenied');
}
next();
}
});
this work as expected, the problem is on the error handler, when i add a simple error handler to the end of my app
app.use(function (err, req, res, next) {
if (isDev) {
console.error(err);
}
res.status(err.status || 500);
res.json(err);
});
The err object is the entire hook object, that is an instance of Error too
i just want to get the error that a throw before on the hook, i try calling next(err)
on the hook but this not work.
Some one can help me with this please?
EDIT
I would like to not delete the hook property on my error handler