MissingControllerException and redirect instead of showing exception page

Hi folks, I am a little baffled as to how I can redirect when I get a missing controller exception. I am using CakePHP 4.3. I have tried to find a solution but it seems I am out of luck. Any solution I have found is very confusing.

Thanks for any help

You will need to create your own error handler for that which redirects on certain exceptions.
https://book.cakephp.org/4/en/development/errors.html#creating-your-own-error-handler

1 Like

thanks for that link! Just what I needed!

I created my own error handler but am lost as to how to capture a MissingControllerException. I am coming from a Rails background and finding CakePHP very very different. Apologies if it is obvious, I am just a little lost.

I followed this; Error & Exception Handling - 4.x

But MissingControllerException is escaping my handler

Nevermind, it was staring me in the face! Figured it out!