Skip to content

Commit af4efae

Browse files
committed
using application/problem+json for json content-type for XMLHttpRequest
1 parent 3bf6b4a commit af4efae

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

config/error-hero-module.local.php.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ return [
5959
'ajax' => [
6060
'message' => <<<json
6161
{
62-
"error": "We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
62+
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
63+
"title": "Internal Server Error",
64+
"status": 500,
65+
"detail": "We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
6366
}
6467
json
6568
],

spec/Fixture/autoload-for-xmlhttprequest/error-hero-module.local.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@
6767
'ajax' => [
6868
'message' => <<<json
6969
{
70-
"error": "We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
70+
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
71+
"title": "Internal Server Error",
72+
"status": 500,
73+
"detail": "We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
7174
}
7275
json
7376
],

spec/IntegrationViaErrorPreviewControllerForXmlHttpRequestSpec.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959

6060
expect($content)->toBe(<<<json
6161
{
62-
"error": "We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
62+
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
63+
"title": "Internal Server Error",
64+
"status": 500,
65+
"detail": "We have encountered a problem and we can not fulfill your request. An error report has been generated and send to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
6366
}
6467
json
6568
);

src/Listener/Mvc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function showDefaultViewWhenDisplayErrorSetttingIsDisabled()
162162
isset($this->errorHeroModuleConfig['display-settings']['ajax']['message'])
163163
) {
164164
$content = $this->errorHeroModuleConfig['display-settings']['ajax']['message'];
165-
$contentType = ((new JsonParser())->lint($content) === null) ? 'application/json' : 'text/html';
165+
$contentType = ((new JsonParser())->lint($content) === null) ? 'application/problem+json' : 'text/html';
166166

167167
$response->getHeaders()->addHeaderLine('Content-type', $contentType);
168168
$response->setContent($content);

0 commit comments

Comments
 (0)