private function getDebugTraceResponse(\Exception $exception, $statusCode)
    {
        $request = $this->application->getRequest();
        $response = (new \Symfony\Component\Debug\ExceptionHandler())->createResponse($exception);
        $response->setStatusCode($statusCode);

        if (in_array('application/json', $request->getAcceptableContentTypes())) {
            $response = new JsonResponse($response->getContent(), $response->getStatusCode(), $response->headers->all());
        }

        return $response;
    }