Issue Feature Closed

#69388Remove limitation: Ajax error status is hard coded

Thomas Mayer 08/28/15, 12:19 updated 03/04/20, 21:02

Description

As of TYPO3 CMS 7.5.0-dev, 85ce761, the http status for ajax errors is hard coded:

TYPO3\CMS\Core\Http\AjaxRequestHandler

protected function renderAsError() {
    /** @var Response $response */
    $response = GeneralUtility::makeInstance(Response::class);
    $response = $response
        ->withStatus(500, ' (AJAX)')
        ->withHeader('Content-type', 'text/xml; charset=utf-8')
        ->withHeader('X-JSON', 'false');
    $response->getBody()->write('<t3err>' . htmlspecialchars($this->errorMessage) . '</t3err>');
    return $response;
}

Suggestion would be to allow context specific http status codes. Status 500 stands for “Internal Server Error” which might be not suitable in many cases and blocks easy debugging.

Compare with the approach Twitter API has: https://dev.twitter.com/overview/api/response-codes.

A simple setter should do while status code 500 could still remain as a default. Which renders this issue non-breaking.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.