FatalThrowableError.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. }