Skip to content

Commit 3b0106a

Browse files
committed
fix: handle early exception correctly
1 parent cf7da48 commit 3b0106a

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Classes/Controller/ErrorPageController.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Netlogix\Nxerrorhandler\Service\StaticDocumentOutputService;
88
use Psr\Http\Message\ServerRequestInterface;
99
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
10+
use TYPO3\CMS\Core\Http\ServerRequestFactory;
1011
use TYPO3\CMS\Core\Utility\GeneralUtility;
1112

1213
#[Autoconfigure(public: true)]
@@ -18,11 +19,15 @@ public function errorAction(
1819
int $errorCode = 0,
1920
?int $httpStatusCode = null,
2021
): string {
21-
$output = GeneralUtility::makeInstance(StaticDocumentOutputService::class)->getOutput(
22-
$httpStatusCode ?? 500,
23-
$this->getRequest(),
24-
$message,
25-
);
22+
try {
23+
$output = GeneralUtility::makeInstance(StaticDocumentOutputService::class)->getOutput(
24+
$httpStatusCode ?? 500,
25+
$this->getRequest(),
26+
$message,
27+
);
28+
} catch (\Throwable) {
29+
$output = '';
30+
}
2631

2732
if ($output === '') {
2833
return parent::errorAction($title, $message, $errorCode, $httpStatusCode);
@@ -33,6 +38,9 @@ public function errorAction(
3338

3439
private function getRequest(): ServerRequestInterface
3540
{
36-
return $GLOBALS['TYPO3_REQUEST'];
41+
if (array_key_exists('TYPO3_REQUEST', $GLOBALS)) {
42+
return $GLOBALS['TYPO3_REQUEST'];
43+
}
44+
return ServerRequestFactory::fromGlobals();
3745
}
3846
}

0 commit comments

Comments
 (0)