Skip to content

Commit 3d79d9f

Browse files
Merge branch '6.2' into 6.3
* 6.2: Avoid call on null [Notifier] Document Firebase options object in readme [ErrorHandler] Fix sending Vary header with SerializerErrorRenderer Fix intl data tests Improve the description of the Intl component [DoctrineBridge] fix issue with missing stopwatch events [HttpClient] Fix canceling MockResponse
2 parents 778b1de + e95f127 commit 3d79d9f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ErrorRenderer/SerializerErrorRenderer.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(SerializerInterface $serializer, string|callable $fo
4444

4545
public function render(\Throwable $exception): FlattenException
4646
{
47-
$headers = [];
47+
$headers = ['Vary' => 'Accept'];
4848
$debug = \is_bool($this->debug) ? $this->debug : ($this->debug)($exception);
4949
if ($debug) {
5050
$headers['X-Debug-Exception'] = rawurlencode($exception->getMessage());
@@ -55,19 +55,17 @@ public function render(\Throwable $exception): FlattenException
5555

5656
try {
5757
$format = \is_string($this->format) ? $this->format : ($this->format)($flattenException);
58-
$headers = [
59-
'Content-Type' => Request::getMimeTypes($format)[0] ?? $format,
60-
'Vary' => 'Accept',
61-
];
58+
$headers['Content-Type'] = Request::getMimeTypes($format)[0] ?? $format;
6259

63-
return $flattenException->setAsString($this->serializer->serialize($flattenException, $format, [
60+
$flattenException->setAsString($this->serializer->serialize($flattenException, $format, [
6461
'exception' => $exception,
6562
'debug' => $debug,
66-
]))
67-
->setHeaders($flattenException->getHeaders() + $headers);
63+
]));
6864
} catch (NotEncodableValueException) {
69-
return $this->fallbackErrorRenderer->render($exception);
65+
$flattenException = $this->fallbackErrorRenderer->render($exception);
7066
}
67+
68+
return $flattenException->setHeaders($flattenException->getHeaders() + $headers);
7169
}
7270

7371
public static function getPreferredFormat(RequestStack $requestStack): \Closure

0 commit comments

Comments
 (0)