@@ -55,7 +55,8 @@ public function __construct(SerializerInterface $serializer, $format, ErrorRende
5555 */
5656public function render (\Throwable $ exception ):FlattenException
5757 {
58- $ headers = [];
58+ $ headers = ['Vary ' =>'Accept ' ];
59+
5960$ debug =\is_bool ($ this ->debug ) ?$ this ->debug : ($ this ->debug )($ exception );
6061if ($ debug ) {
6162$ headers ['X-Debug-Exception ' ] =rawurlencode ($ exception ->getMessage ());
@@ -66,19 +67,17 @@ public function render(\Throwable $exception): FlattenException
6667
6768try {
6869$ format =\is_string ($ this ->format ) ?$ this ->format : ($ this ->format )($ flattenException );
69- $ headers = [
70- 'Content-Type ' => Request::getMimeTypes ($ format )[0 ] ??$ format ,
71- 'Vary ' =>'Accept ' ,
72- ];
70+ $ headers ['Content-Type ' ] = Request::getMimeTypes ($ format )[0 ] ??$ format ;
7371
74- return $ flattenException ->setAsString ($ this ->serializer ->serialize ($ flattenException ,$ format , [
72+ $ flattenException ->setAsString ($ this ->serializer ->serialize ($ flattenException ,$ format , [
7573'exception ' =>$ exception ,
7674'debug ' =>$ debug ,
77- ]))
78- ->setHeaders ($ flattenException ->getHeaders () +$ headers );
75+ ]));
7976 }catch (NotEncodableValueException $ e ) {
80- return $ this ->fallbackErrorRenderer ->render ($ exception );
77+ $ flattenException = $ this ->fallbackErrorRenderer ->render ($ exception );
8178 }
79+
80+ return $ flattenException ->setHeaders ($ flattenException ->getHeaders () +$ headers );
8281 }
8382
8483public static function getPreferredFormat (RequestStack $ requestStack ):\Closure