try this
module.exports = () => {
return async (ctx, next) => {
try{
await next();
}catch{
if (ctx.request.url === “/api/auth/local” && ctx.response.status === 404) {
return ctx.badRequest(“Email or password - invalid. Please try again”);
};
}
};
};