diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php index cec8e4d413dce..4d1e752dc1ffe 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/SerializerErrorRenderer.php @@ -55,7 +55,7 @@ public function __construct(SerializerInterface $serializer, $format, ErrorRende */ public function render(\Throwable $exception): FlattenException { - $headers = []; + $headers = ['Vary' => 'Accept']; $debug = \is_bool($this->debug) ? $this->debug : ($this->debug)($exception); if ($debug) { $headers['X-Debug-Exception'] = rawurlencode($exception->getMessage()); @@ -66,19 +66,17 @@ public function render(\Throwable $exception): FlattenException try { $format = \is_string($this->format) ? $this->format : ($this->format)($flattenException); - $headers = [ - 'Content-Type' => Request::getMimeTypes($format)[0] ?? $format, - 'Vary' => 'Accept', - ]; + $headers['Content-Type'] = Request::getMimeTypes($format)[0] ?? $format; - return $flattenException->setAsString($this->serializer->serialize($flattenException, $format, [ + $flattenException->setAsString($this->serializer->serialize($flattenException, $format, [ 'exception' => $exception, 'debug' => $debug, - ])) - ->setHeaders($flattenException->getHeaders() + $headers); + ])); } catch (NotEncodableValueException $e) { - return $this->fallbackErrorRenderer->render($exception); + $flattenException = $this->fallbackErrorRenderer->render($exception); } + + return $flattenException->setHeaders($flattenException->getHeaders() + $headers); } public static function getPreferredFormat(RequestStack $requestStack): \Closure
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: