4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\DataCollector;
14 use Symfony\Component\Debug\Exception\FlattenException;
15 use Symfony\Component\HttpFoundation\Request;
16 use Symfony\Component\HttpFoundation\Response;
19 * ExceptionDataCollector.
21 * @author Fabien Potencier <fabien@symfony.com>
23 class ExceptionDataCollector extends DataCollector
28 public function collect(Request $request, Response $response, \Exception $exception = null)
30 if (null !== $exception) {
32 'exception' => FlattenException::create($exception),
40 public function reset()
42 $this->data = array();
46 * Checks if the exception is not null.
48 * @return bool true if the exception is not null, false otherwise
50 public function hasException()
52 return isset($this->data['exception']);
58 * @return \Exception The exception
60 public function getException()
62 return $this->data['exception'];
66 * Gets the exception message.
68 * @return string The exception message
70 public function getMessage()
72 return $this->data['exception']->getMessage();
76 * Gets the exception code.
78 * @return int The exception code
80 public function getCode()
82 return $this->data['exception']->getCode();
86 * Gets the status code.
88 * @return int The status code
90 public function getStatusCode()
92 return $this->data['exception']->getStatusCode();
96 * Gets the exception trace.
98 * @return array The exception trace
100 public function getTrace()
102 return $this->data['exception']->getTrace();
108 public function getName()