How to display ajax error with logic hook

Hello everyone. We recently upgraded from suitecrm7 to suitecrm 8.3.1 and we have a lot of logic hooks from suitecrm7. They work fine, but we would like to improve our error display. So far for suitecrm 7 we have been using the syntax


but sadly in suitecrm8 this message is only displayed when we got to the home page. We would like to implement the same structure as the error messages / validation messages that we see upon creating an entity like an account: these are the ones that are displayed in real time, on the same page, without page reload. So far I was able to gather that it seems to use the Process class

when using the “unexpected error when calling action” message

The new syntax was found in
core\backend\Process\Service\BulkActions\MassUpdateBulkAction.php line 167

I’m wondering if there is a simple way to implement that for the logic hooks. Feel free to ask me for more information, and thanks for your time.