• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nette / application / 27919019709

21 Jun 2026 10:08PM UTC coverage: 84.111% (+0.05%) from 84.059%
27919019709

push

github

dg
phpstan fix

2038 of 2423 relevant lines covered (84.11%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Application/ErrorPresenter.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace NetteModule;
9

10
use Nette\Application;
11
use Nette\Http;
12
use Tracy\ILogger;
13

14

15
/**
16
 * Default Error Presenter.
17
 */
18
final class ErrorPresenter implements Application\IPresenter
19
{
20
        public function __construct(
×
21
                private readonly ?ILogger $logger = null,
22
        ) {
23
        }
24

25

26
        public function run(Application\Request $request): Application\Response
27
        {
28
                $e = $request->getParameter('exception');
×
29
                if ($e instanceof Application\BadRequestException) {
×
30
                        $code = $e->getHttpCode();
×
31
                } else {
32
                        $code = 500;
×
33
                        $this->logger?->log($e, ILogger::EXCEPTION);
×
34
                }
35

36
                return new Application\Responses\CallbackResponse(function (Http\IRequest $httpRequest, Http\IResponse $httpResponse) use ($code): void {
×
37
                        if (preg_match('#^text/html(?:;|$)#', (string) $httpResponse->getHeader('Content-Type'))) {
38
                                require __DIR__ . '/templates/error.phtml';
39
                        }
40
                });
×
41
        }
42
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc