Creates the error Response associated with the given Exception.
\Exception|FlattenException $exception An \Exception instance:
public function createResponse($exception) {
$content = '';
$title = '';
try {
if (!$exception instanceof FlattenException) {
$exception = FlattenException::create($exception);
}
switch ($exception
->getStatusCode()) {
case 404:
$title = 'Sorry, the page you are looking for could not be found.';
break;
default:
$title = 'Whoops, looks like something went wrong.';
}
if ($this->debug) {
$content = $this
->getContent($exception);
}
} catch (\Exception $e) {
// something nasty happened and we cannot throw an exception here anymore
if ($this->debug) {
$title = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($exception), $exception
->getMessage());
}
else {
$title = 'Whoops, looks like something went wrong.';
}
}
return new Response($this
->decorate($content, $title), $exception
->getStatusCode(), $exception
->getHeaders());
}