Feature: #108904 - Add generic error action for custom HTTP status codes in ErrorController
See forge#108904
Description
The
\TYPO3\ has been enhanced with
a new method
custom which allows custom error handling
for HTTP status codes.
The new method can be used with TYPO3 site error handling, allowing site administrators to configure dedicated error handling (for example, rendering a Fluid template) for a given status code.
Example of usage in an Extbase action:
use TYPO3\CMS\Core\Http\PropagateResponseException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\ErrorController;
$response = GeneralUtility::makeInstance(ErrorController::class)->customErrorAction(
$this->request,
429,
'Rate limit exceeded.',
'You have exceeded the rate limit.'
);
throw new PropagateResponseException($response, 1771065101);
Copied!
Impact
It is now possible to trigger custom error pages with specific HTTP status codes and messages from within TYPO3 or extensions, while still respecting the error handling in the main site configuration.