serializer = $serializer; } /** * @param Error $error * @param int $statusCode * @param array $headers * * @return Response */ public function create(Error $error, int $statusCode = Response::HTTP_BAD_REQUEST, array $headers = []): Response { return JsonResponse::fromJsonString( $this->serializer->serialize($error, 'json'), $statusCode, $headers ); } }