Handling ErrorsΒΆ

Frankie can’t react to 404 pages (no routes) because there is no action to analyze and preapare and also for any 500 errors (other exceptions).

For that reason the app expose a method in order to register a callable for this kind of situations.

$app = Factory\AppFactory::create(...);
$app->setErrorHandler(function(Request $request, Response $response, $e) {

The setErrorHandler method allows any callable type, for example:

class JsonErrorHandler
    public function __invoke(Request $request, Response $response, Exception $e) {
                "error" => [
                    "message" => $e->getMessage(),
                    "stacktrace" => $e->getTraceAsString(),

That’s it!