This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

lunfel
lunfel

I know how to throw 404 from a component and I know how to do global exception handling

What I am looking to do is when I am handling an exception, I want to throw a 404. Here is a temptative code snippet that does not work.

// Plugin.php from any plugin
public function boot()
{
    App::error(function (ModelNotFoundException $exception) {
        // return \Response::make($this->controller->run('404'), 404);
    });
}

Unfortunately I do not have access to the controller from $this. How would go about doing a 404 at that point?

Webp
Webp

you could run abort(404);

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.