I know of $di->notFound()
and a solution based on middleware, but that is triggered only for non-matching URLs. But I want to do something like this:
class MyController {
public function myAction() {
$person = Persons::findFirst();
if (!$person) {
throw new NotFoundException();
}
}
}
For this, I've created a custom error handler. What I not want to do is redirecting to a special /404
page. I want to render a custom error page for 404 errors (raised by NotFoundMiddleware
and NotFoundException
) and 500 errors (raised by any exception) without redirecting user.
As micro app is lacking a dispatcher (so ->forward()
is not useable), is there any clean way to solve this?