FatalThrowableError.php 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Debug\Exception;
  11. /**
  12. * Fatal Throwable Error.
  13. *
  14. * @author Nicolas Grekas <p@tchwork.com>
  15. */
  16. class FatalThrowableError extends FatalErrorException
  17. {
  18. private $originalClassName;
  19. public function __construct(\Throwable $e)
  20. {
  21. $this->originalClassName = \get_class($e);
  22. if ($e instanceof \ParseError) {
  23. $severity = E_PARSE;
  24. } elseif ($e instanceof \TypeError) {
  25. $severity = E_RECOVERABLE_ERROR;
  26. } else {
  27. $severity = E_ERROR;
  28. }
  29. \ErrorException::__construct(
  30. $e->getMessage(),
  31. $e->getCode(),
  32. $severity,
  33. $e->getFile(),
  34. $e->getLine(),
  35. $e->getPrevious()
  36. );
  37. $this->setTrace($e->getTrace());
  38. }
  39. public function getOriginalClassName(): string
  40. {
  41. return $this->originalClassName;
  42. }
  43. }