Throw customized Error Message for Data Objects from PHP Code

Hello,

I am relatively new to Pimcore and I want to know how can we throw an error message while saving the object. I have found about the Events which are triggered when we save object and we can implement our own function in a class. But what then? How do we show the error or customized message from the code?
Could you please help me. Thanks a lot in advance.
Regards,
Akansh

Hi,
see https://pimcore.com/docs/5.x/Development_Documentation/Extending_Pimcore/Bundle_Developers_Guide/Plugin_Backend_UI.html#page_Validate-Pimcore-Object-s-Data-in-frontend-before-saving

BR
Christian

Thanks fash
I have already tried your suggestions…
But the problem is this solution only works for the Javascript code but I need to show the error message from the PHP code.
Thanks again.

@akansh Just simply throw error or exception from your php code.