Skip to content

Commit

Permalink
resolve error code
Browse files Browse the repository at this point in the history
  • Loading branch information
Headary committed Aug 30, 2024
1 parent 5c39d25 commit 1b722b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/Modules/Fykos/DefaultModule/ErrorPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ public function injectLogger(ILogger $logger): void
public function renderDefault(\Throwable $exception): void
{
if ($exception instanceof BadRequestException) {
$code = $exception->getCode();

// specifically return 410 instead of 404 for these paths
if (in_array($this->getHttpRequest()->getUrl()->getPath(), ['/prezentace'])) {
$code = 410;
$this->getHttpResponse()->setCode(410);
}

// load template 403.latte or 404.latte or ... 4xx.latte
$this->setView(in_array($code, [403, 404, 405, 410, 500, 503]) ? (string)$code : '4xx');

// log to access.log
$this->logger->log(
"HTTP code $code: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}",
Expand Down
2 changes: 2 additions & 0 deletions app/Modules/Fykos/DefaultModule/templates/Error/410.latte
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
{switch $language->value}
{case 'cs'}
<p>Požadovaná stránka se již na webu nenachází.</p>
<p>Můžete přejít na <a n:href='Default:default'>hlavní stránku</a>.</p>

<p><small>error 410</small></p>
{default}
<p>The page you requested has been taken off the site.</p>
<p>Visit the <a n:href='Default:default'>front page</a>.</p>

<p><small>error 410</small></p>
{/switch}
Expand Down

0 comments on commit 1b722b3

Please sign in to comment.