Costume validation for before Update(PUT)

hi cuba team ,i have one costume validation for before update entity listener .when i run the cuba update REST API in postman it show “data error” but i want to costume exception . bellow i mention the code.

        @Component("matrimony_ProfileDetailsEntityListener")
      public class ProfileDetailsEntityListener implements BeforeUpdateEntityListener<ProfileDetails> {

      private Logger log = LoggerFactory.getLogger(UserDetailsServiceBean.class);

      	@Override
         public void onBeforeUpdate (ProfileDetails entity, EntityManager entityManager) {
         	    			

         	Query query = entityManager.createQuery("select u from matrimony$ProfileDetails u where  u.profileMobileNo = :mobile and id: != currentID");
        	        
      	query.setParameter("mobile", entity.getProfileMobileNo());
         	query.setParameter("currentID", entity.getId());
            
             List<?> count =  query.getResultList();
           	
         	if (count.size() > 0) {
            		log.warn("------->Service call error: A user with the same email/mobile already exists : "	+ entity.getProfileMobileNo());
          		throw new ValidationException("The mobile Number is already registerd!");
           		}
    
      **`Preformatted text`	}}

i want to print my costume validation error message.

Maybe this post https://www.cuba-platform.com/discuss/t/user-defined-exceptions/4679 can help you.