1: <?php
2: 3: 4: 5:
6:
7: use Nette\Diagnostics\Debugger,
8: Nette\Application as NA;
9:
10: 11: 12:
13: class ErrorPresenter extends BasePresenter
14: {
15:
16: 17: 18: 19: 20:
21: public function renderDefault($exception)
22: {
23: if ($this->isAjax()) {
24: $this->payload->error = TRUE;
25: $this->terminate();
26:
27: } elseif ($exception instanceof NA\BadRequestException) {
28: $code = $exception->getCode();
29:
30: $this->setView(in_array($code, array(403, 404, 405, 410, 500)) ? $code : '4xx');
31:
32: Debugger::log("HTTP code $code: {$exception->getMessage()} in {$exception->getFile()}:{$exception->getLine()}", 'access');
33:
34: } else {
35: $this->setView('500');
36: Debugger::log($exception, Debugger::ERROR);
37: }
38: }
39:
40: }
41: