This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php

53 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace Symfony\Bundle\FrameworkBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Debug\ExceptionManager;
/*
* This file is part of the Symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
2010-04-07 02:07:59 +01:00
* ExceptionController.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ExceptionController extends Controller
{
/**
* Converts an Exception to a Response.
*
* @param ExceptionManager $manager An ExceptionManager instance
*
* @throws \InvalidArgumentException When the exception template does not exist
*/
public function exceptionAction(ExceptionManager $manager, $format)
{
$this['request']->setRequestFormat($format);
$currentContent = '';
while (false !== $content = ob_get_clean()) {
$currentContent .= $content;
}
$response = $this->render(
'FrameworkBundle:Exception:'.($this['kernel']->isDebug() ? 'exception' : 'error'),
array(
'manager' => $manager,
'managers' => $manager->getLinkedManagers(),
'currentContent' => $currentContent,
)
);
$response->setStatusCode($manager->getStatusCode());
return $response;
}
}