Exception
Throwing exceptions will automatically invoke the error page with a matching HTTP status code.
return [
'routes' => [
[
'pattern' => 'custom/response',
'action' => function () {
throw new Exception('Something went horribly wrong');
}
]
]
];