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),
38 * Checks if the exception is not null.
40 * @return bool true if the exception is not null, false otherwise
42 public function hasException()
44 return isset($this->data['exception']);
50 * @return \Exception The exception
52 public function getException()
54 return $this->data['exception'];
58 * Gets the exception message.
60 * @return string The exception message
62 public function getMessage()
64 return $this->data['exception']->getMessage();
68 * Gets the exception code.
70 * @return int The exception code
72 public function getCode()
74 return $this->data['exception']->getCode();
78 * Gets the status code.
80 * @return int The status code
82 public function getStatusCode()
84 return $this->data['exception']->getStatusCode();
88 * Gets the exception trace.
90 * @return array The exception trace
92 public function getTrace()
94 return $this->data['exception']->getTrace();
100 public function getName()