protected function buildErrorResponse(Response $response, $statusCode, $statusMessage, $expose = false)
    {
        // Normalize for Exceptions from other parts of the app.
        if ($statusCode < 200 || $statusCode > 510) {
            $statusCode = 500;
        }

        $body = new Doozr_Response_Body('php://memory', 'w');

        // Do not expose secret information
        if (false === $expose) {
            $statusMessage = constant('Doozr_Http::REASONPHRASE_'.$statusCode);
        }
        $body->write('<h1>'.$statusMessage.'</h1>');

        return $response
            ->withStatus($statusCode, $statusMessage)
            ->withBody($body);
    }