From 7ea7cd542ed4059ac35b18ba98008462882e450a Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Fri, 29 Nov 2024 14:13:14 +0100 Subject: [PATCH] fix: Handle correctly invalid HTTP method errors --- public/index.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/public/index.php b/public/index.php index 01d8775f..321ef5f8 100644 --- a/public/index.php +++ b/public/index.php @@ -13,16 +13,19 @@ include $app_path . '/vendor/autoload.php'; \App\Configuration::load('dotenv', $app_path); -// Get the http information and create a Request -$request = \Minz\Request::initFromGlobals(); - // Initialize the Application and execute the request to get a Response try { $application = new \App\Application(); + + $request = \Minz\Request::initFromGlobals(); + $response = $application->run($request); +} catch (\Minz\Errors\RequestError $e) { + $response = \Minz\Response::notFound('not_found.phtml', [ + 'error' => $e, + ]); } catch (\Exception $e) { $response = \Minz\Response::internalServerError('internal_server_error.phtml', [ - 'environment' => \App\Configuration::$environment, 'error' => $e, ]); }