Catch HTTPExceptions in App::runFrontend()
Set correct http response header, display error message using "404.tpl"
This commit is contained in:
parent
b96dbcd4cb
commit
89eaf508f1
1 changed files with 55 additions and 44 deletions
11
src/App.php
11
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;
|
||||
|
||||
/**
|
||||
|
@ -1718,6 +1719,8 @@ class App
|
|||
}
|
||||
}
|
||||
|
||||
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
|
||||
try {
|
||||
$content = '';
|
||||
|
||||
// Initialize module that can set the current theme in the init() method, either directly or via App->profile_uid
|
||||
|
@ -1774,6 +1777,14 @@ class App
|
|||
}
|
||||
|
||||
$this->page['content'] .= $content;
|
||||
} 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
|
||||
* and getting any auth credentials.
|
||||
|
|
Loading…
Reference in a new issue