菜谱项目

FatalThrowableError.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. public function __construct(\Throwable $e)
  19. {
  20. if ($e instanceof \ParseError) {
  21. $message = 'Parse error: '.$e->getMessage();
  22. $severity = E_PARSE;
  23. } elseif ($e instanceof \TypeError) {
  24. $message = 'Type error: '.$e->getMessage();
  25. $severity = E_RECOVERABLE_ERROR;
  26. } else {
  27. $message = $e->getMessage();
  28. $severity = E_ERROR;
  29. }
  30. \ErrorException::__construct(
  31. $message,
  32. $e->getCode(),
  33. $severity,
  34. $e->getFile(),
  35. $e->getLine()
  36. );
  37. $this->setTrace($e->getTrace());
  38. }
  39. }