2010-08-28 14:23:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Symfony\Component\HttpKernel\DataCollector;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
2010-08-29 10:52:55 +01:00
|
|
|
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
2010-08-28 14:23:21 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ExceptionDataCollector.
|
|
|
|
*
|
|
|
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
|
*/
|
|
|
|
class ExceptionDataCollector extends DataCollector
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function collect(Request $request, Response $response, \Exception $exception = null)
|
|
|
|
{
|
|
|
|
if (null !== $exception) {
|
|
|
|
$this->data = array(
|
2010-08-29 10:52:55 +01:00
|
|
|
'exception' => FlattenException::create($exception),
|
2010-08-28 14:23:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the exception is not null.
|
|
|
|
*
|
|
|
|
* @return Boolean true if the exception is not null, false otherwise
|
|
|
|
*/
|
|
|
|
public function hasException()
|
|
|
|
{
|
|
|
|
return isset($this->data['exception']);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the exception.
|
|
|
|
*
|
|
|
|
* @return \Exception The exception
|
|
|
|
*/
|
|
|
|
public function getException()
|
|
|
|
{
|
|
|
|
return $this->data['exception'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the exception message.
|
|
|
|
*
|
|
|
|
* @return string The exception message
|
|
|
|
*/
|
|
|
|
public function getMessage()
|
|
|
|
{
|
|
|
|
return $this->data['exception']->getMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the exception code.
|
|
|
|
*
|
|
|
|
* @return integer The exception code
|
|
|
|
*/
|
|
|
|
public function getCode()
|
|
|
|
{
|
|
|
|
return $this->data['exception']->getCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the exception trace.
|
|
|
|
*
|
|
|
|
* @return array The exception trace
|
|
|
|
*/
|
|
|
|
public function getTrace()
|
|
|
|
{
|
|
|
|
return $this->data['exception']->getTrace();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
return 'exception';
|
|
|
|
}
|
|
|
|
}
|