Skip to content

Commit 8209936

Browse files
committed
ErrorPresenter: renders error.phtml only in HTML
1 parent 44e6e02 commit 8209936

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Application/ErrorPresenter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Nette;
1313
use Nette\Application;
14+
use Nette\Http;
1415
use Tracy\ILogger;
1516

1617

@@ -42,8 +43,10 @@ public function run(Application\Request $request): Application\IResponse
4243
$this->logger->log($e, ILogger::EXCEPTION);
4344
}
4445
}
45-
return new Application\Responses\CallbackResponse(function () use ($code) {
46-
require __DIR__ . '/templates/error.phtml';
46+
return new Application\Responses\CallbackResponse(function (Http\IRequest $httpRequest, Http\IResponse $httpResponse) use ($code) {
47+
if (preg_match('#^text/html(?:;|$)#', $httpResponse->getHeader('Content-Type'))) {
48+
require __DIR__ . '/templates/error.phtml';
49+
}
4750
});
4851
}
4952
}

0 commit comments

Comments
 (0)