annotate vendor/symfony/http-kernel/DataCollector/ExceptionDataCollector.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children a9cd425dd02b
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\HttpKernel\DataCollector;
Chris@0 13
Chris@0 14 use Symfony\Component\Debug\Exception\FlattenException;
Chris@0 15 use Symfony\Component\HttpFoundation\Request;
Chris@0 16 use Symfony\Component\HttpFoundation\Response;
Chris@0 17
Chris@0 18 /**
Chris@0 19 * ExceptionDataCollector.
Chris@0 20 *
Chris@0 21 * @author Fabien Potencier <fabien@symfony.com>
Chris@0 22 */
Chris@0 23 class ExceptionDataCollector extends DataCollector
Chris@0 24 {
Chris@0 25 /**
Chris@0 26 * {@inheritdoc}
Chris@0 27 */
Chris@0 28 public function collect(Request $request, Response $response, \Exception $exception = null)
Chris@0 29 {
Chris@0 30 if (null !== $exception) {
Chris@0 31 $this->data = array(
Chris@0 32 'exception' => FlattenException::create($exception),
Chris@0 33 );
Chris@0 34 }
Chris@0 35 }
Chris@0 36
Chris@0 37 /**
Chris@0 38 * {@inheritdoc}
Chris@0 39 */
Chris@0 40 public function reset()
Chris@0 41 {
Chris@0 42 $this->data = array();
Chris@0 43 }
Chris@0 44
Chris@0 45 /**
Chris@0 46 * Checks if the exception is not null.
Chris@0 47 *
Chris@0 48 * @return bool true if the exception is not null, false otherwise
Chris@0 49 */
Chris@0 50 public function hasException()
Chris@0 51 {
Chris@0 52 return isset($this->data['exception']);
Chris@0 53 }
Chris@0 54
Chris@0 55 /**
Chris@0 56 * Gets the exception.
Chris@0 57 *
Chris@0 58 * @return \Exception The exception
Chris@0 59 */
Chris@0 60 public function getException()
Chris@0 61 {
Chris@0 62 return $this->data['exception'];
Chris@0 63 }
Chris@0 64
Chris@0 65 /**
Chris@0 66 * Gets the exception message.
Chris@0 67 *
Chris@0 68 * @return string The exception message
Chris@0 69 */
Chris@0 70 public function getMessage()
Chris@0 71 {
Chris@0 72 return $this->data['exception']->getMessage();
Chris@0 73 }
Chris@0 74
Chris@0 75 /**
Chris@0 76 * Gets the exception code.
Chris@0 77 *
Chris@0 78 * @return int The exception code
Chris@0 79 */
Chris@0 80 public function getCode()
Chris@0 81 {
Chris@0 82 return $this->data['exception']->getCode();
Chris@0 83 }
Chris@0 84
Chris@0 85 /**
Chris@0 86 * Gets the status code.
Chris@0 87 *
Chris@0 88 * @return int The status code
Chris@0 89 */
Chris@0 90 public function getStatusCode()
Chris@0 91 {
Chris@0 92 return $this->data['exception']->getStatusCode();
Chris@0 93 }
Chris@0 94
Chris@0 95 /**
Chris@0 96 * Gets the exception trace.
Chris@0 97 *
Chris@0 98 * @return array The exception trace
Chris@0 99 */
Chris@0 100 public function getTrace()
Chris@0 101 {
Chris@0 102 return $this->data['exception']->getTrace();
Chris@0 103 }
Chris@0 104
Chris@0 105 /**
Chris@0 106 * {@inheritdoc}
Chris@0 107 */
Chris@0 108 public function getName()
Chris@0 109 {
Chris@0 110 return 'exception';
Chris@0 111 }
Chris@0 112 }