messagepimcore

Pimcore How to display custom error message in error message box


Hi i am working on pimcore cms.

I am calling custom API while saving objects and it has some custom error message.

Right now pimcore showing

"Object Could not saved".

How to display custom message instead of this default message in error box ?

My API returns error message whenever error occurs but I am stuck on how to pass it with pimcore Error message.

Your help will be appreciated.

Thanks


Solution

  • I presume you are using Pimcore events to do what you are trying to achieve. To display custom message, you just need to throw ValidationException like this:

    throw new \Pimcore\Model\Element\ValidationException("This is your custom error message", 1234);
    

    This is also described in the section Example of custom error handling using the Event API of the documentation here:

    https://www.pimcore.org/docs/latest/Extending_Pimcore/Event_API_and_Event_Manager.html