Try Catch in controller


#1

Hi, can anyone explain me why the following action send the entire exception to the client (when the token isn’t valid or isn’t present) instead of enter in the catch block ?

async self({ response, auth }) {
    try {
      return await auth.getUser();
    }
    catch(error) {
      return response.status(401).send();
    }
  }

#2

Are you using the auth middleare?


#3

This was exactly this, I’m so dumb, I totally forgot that I added it for this route. Thanks