1: <?php
2:
3: 4: 5: 6:
7:
8: namespace NetteModule;
9:
10: use Nette;
11: use Nette\Application;
12: use Nette\Diagnostics\Debugger;
13:
14:
15: 16: 17: 18: 19:
20: class ErrorPresenter extends Nette\Object implements Application\IPresenter
21: {
22:
23: 24: 25:
26: public function run(Application\Request $request)
27: {
28: $e = $request->parameters['exception'];
29: if ($e instanceof Application\BadRequestException) {
30: $code = $e->getCode();
31: } else {
32: $code = 500;
33: Debugger::log($e, Debugger::EXCEPTION);
34: }
35: ob_start();
36: require __DIR__ . '/templates/error.phtml';
37: return new Application\Responses\TextResponse(ob_get_clean());
38: }
39:
40: }
41: