How can I receive the validation error inside the request body as well?

System Information
  • Strapi Version: 3.6.0
  • Operating System: Ubuntu 20.04 LTS x64
  • Database: Postgres
  • Node Version: 14.16.0
  • NPM Version: 6.14.11
  • Yarn Version: -

Hello guys. I have a “clients” collection in my backend and I’m making registration requests from the frontend of my app. When someone tries to register with an email that is already used the POST requests returns a 500 Internal Server Error. However, in my server’s logs I can see that the request wasn’t successful because of this duplicate entry.

My question is, how can I include this validation error in the request response body? I want to tell my users why their registration failed.

Thank you guys!