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

Hi @piwi
What would be the equivalent solution in Strapi v4.0 of the elegant code snippet that @christianguevara has proposed (cf. below) ?
Thanks & Regards,

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');
        	}
        },
      },
2 Likes