From 0bd184da05b30914f7f14dec5842f50bc2e4f093 Mon Sep 17 00:00:00 2001 From: Tezza Date: Sun, 1 Mar 2015 13:01:40 +0100 Subject: [PATCH] handling 404 errors --- src/app/app.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app/app.php b/src/app/app.php index 8a5c8fb..6d2c61d 100644 --- a/src/app/app.php +++ b/src/app/app.php @@ -27,4 +27,15 @@ $app->mount( '/', new level2\WebControllerProvider() ); + $app->error(function (\Exception $e, $code) use ( $app ) { + switch ($code) { + case 404: + return $app->redirect('/'); + default: + $message = 'We are sorry, but something went terribly wrong.'; + } + + return new Response($message); + }); + return $app;