Throw Error message in lifecycle hook doesnt change the error message display in the UI

System Information
  • Strapi Version: 3.3.4
  • Operating System: macOS
  • Database: SQLlite
  • Node Version: 12.18
  • NPM Version:
  • Yarn Version:

I was trying to add some custom validation logic in the “beforeCreate” lifecycle hook, but I was not able to customize the error message displayed in the UI , it is always returning the default one.
I tried to throw a “new Error”(“custom message”)" but no luck there.
Is it something doable ?


I did it in this way:

module.exports = {
      lifecycles: {
        beforeCreate(data) {
        	if (someCondition(data)) {
        		// throw error here, it will prevent the entry creation
        		throw strapi.errors.badRequest('Some message you want to show in the admin UI');