Server error místo error 404ky
- FJP
- Člen | 124
Servus, laděnka vypisuje
BadRequestException #404 No route for HTTP request.
Requests: array (), Presenter: NULL
A na produkci to hazi server error. A takto vypadá error presenter:
<?php
namespace App\Presenters;
use Nette,
App\Model,
Nette\Diagnostics\Debugger;
/**
* Error presenter.
*/
class ErrorPresenter extends BasePresenter
{
/**
* @param Exception
* @return void
*/
public function renderDefault($exception)
{
if ($this->isAjax()) { // AJAX request? Note this error in payload.
$this->payload->error = TRUE;
$this->terminate();
} elseif ($exception instanceof \Nette\Application\BadRequestException) {
$code = $exception->getCode();
//var_dump($code);
// load template 403.latte or 404.latte or ... 4xx.latte
$this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx');
// log to access.log
Debugger::log("HTTP code $code: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access');
} else {
$this->setView('500'); // load template 500.latte
Debugger::log($exception, Debugger::ERROR); // and log exception
}
}
}
Když odkomentuji dump, vyhodí to 404 … ale nechce to načíst správnou šablonu. Zajímavé ovšem je, že v šabloně mám:
{block content}
{var $robots = noindex}
{define description}ERROR 404{/define}
{define keywords}error, 404, not found, nenalezeno{/define}
...
<h1 n:block="title">Error 404</h1>
...
Co je definované v <h1 n:block=„title“>Error 404</h1> ovšem jde do tagu <title></title> správně. Ale v obsahu stránky se vypisuje výchozí nettí error.
Díky za rady.
- FJP
- Člen | 124
Ahoj tohle mi vyhazuje exception:
object(Nette\Application\BadRequestException)#41 (8) { [defaultCode int(404) [message string(26) „No route for HTTP request.“ [„string“:Exception string(0) "" [code int(404) [file string(83) „/var/www/html/www.hecnuto.cz/vendor/nette/nette/Nette/Application/Application.php“ [line int(117) [„trace“:Exception array(2) { [0]⇒ array(6) { [„file“]⇒ string(83) „/var/www/html/www.hecnuto.cz/vendor/nette/nette/Nette/Application/Application.php“ [„line“]⇒ int(88) [„function“]⇒ string(20) „createInitialRequest“ [„class“]⇒ string(29) „Nette\Application\Application“ [„type“]⇒ string(2) „->“ [„args“]⇒ array(0) { } } [1]⇒ array(6) { [„file“]⇒ string(44) „/var/www/html/www.hecnuto.cz/www/index.php“ [„line“]⇒ int(8) [„function“]⇒ string(3) „run“ [„class“]⇒ string(29) „Nette\Application\Application“ [„type“]⇒ string(2) „->“ [„args“]⇒ array(0) { } } } [„previous“:Exception NULL }
Ale v do té šablony se pořád vkresluje obsah 500ky…
- David Matějka
- Moderator | 6445
A do logu na produkci se nic neulozilo? tohle vypada na klasicky „an error occurred while executing error presenter“ nebo jak to je..
zkus si na dev zapnout chytani chyb v neonu:
nette:
application:
catchExceptions: true
a zkus pak vyvolat tu 404…