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