diff --git a/index.php b/index.php index 06fbf51..edb45c5 100644 --- a/index.php +++ b/index.php @@ -17,6 +17,8 @@ View::openBuffer(); $ret = Utils::RETURN_HTML; + $I_err_httpCode = null; + $S_err_msg = null; try { @@ -26,17 +28,29 @@ catch (ControleurException $O_exception) { View::openBuffer(); - View::show("errors/500", $O_exception->getMsg()); + $I_err_httpCode = 500; + $S_err_msg = $O_exception->getMsg(); } catch (NotFoundException $O_exception) { View::openBuffer(); - View::show("errors/404"); + $I_err_httpCode = 404; } catch (HTTPSpecialCaseException $O_exception) { View::openBuffer(); - View::show("errors/".$O_exception->getHTTPCode(), $O_exception->getMsg()); + $I_err_httpCode = $O_exception->getHTTPCode(); + $S_err_msg = $O_exception->getMsg(); + } + + if ($I_err_httpCode !== null) { + http_response_code($I_err_httpCode); + + if($I_err_httpCode === 500 || $I_err_httpCode === 400) { + header_remove("Location"); + } + + View::show("errors/".$I_err_httpCode, $S_err_msg); }