Output in hooks is not intended and this won’t work because the Panel frontend expects a JSON response. If there’s some kind of other output, it breaks the JSON.
I see. It’s a difficult to have a smooth debug experience with the hooks of today.
Would it be possible to return as html and convert the response on the PHP side? Then a simple validation could be made to see if it’s a JSON. If not, output an error message in a modal, if for example debug mode is true in the config.
That’s sounds a bit error-prone. What could work though is to capture output from the hooks using PHP’s output buffer and if that output is not empty tell the frontend to display it in a modal. Not sure how complex that is however.