Catch HTTPExceptions in App::runFrontend()
Set correct http response header, display error message using "404.tpl"
This commit is contained in:
parent
36c8828b32
commit
58bd75f8f3
1 changed files with 42 additions and 32 deletions
10
src/App.php
10
src/App.php
|
@ -9,6 +9,7 @@ use DOMDocument;
|
|||
use DOMXPath;
|
||||
use Exception;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
|
||||
require_once 'boot.php';
|
||||
|
@ -1684,6 +1685,7 @@ class App
|
|||
|
||||
// Call module functions
|
||||
if ($this->module_loaded) {
|
||||
try {
|
||||
$this->page['page_title'] = $this->module;
|
||||
$placeholder = '';
|
||||
|
||||
|
@ -1725,6 +1727,14 @@ class App
|
|||
$func = str_replace('-', '_', $this->getCurrentTheme()) . '_content_loaded';
|
||||
$func($this);
|
||||
}
|
||||
} catch (HTTPException $e) {
|
||||
header($_SERVER["SERVER_PROTOCOL"] . " " . $e->httpcode . " " . $e->httpdesc , true, $e->httpcode);
|
||||
$error = ($e->getMessage() !== "" ? $e->getMessage() : $e->httpdesc);
|
||||
$tpl = Core\Renderer::getMarkupTemplate("404.tpl");
|
||||
$this->page['content'] = Core\Renderer::replaceMacros($tpl, [
|
||||
'$message' => $error
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create the page head after setting the language
|
||||
|
|
Loading…
Reference in a new issue