refactor index.php, set http code, and remove header Location on error 400 and 500
This commit is contained in:
parent
f703f9342d
commit
f6be185af5
20
index.php
20
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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user