ErrorHandlingUtils.php 1015 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Knuckles\Scribe\Tools;
  3. use Symfony\Component\Console\Output\ConsoleOutput;
  4. use Symfony\Component\Console\Output\OutputInterface;
  5. class ErrorHandlingUtils
  6. {
  7. public static function dumpException(\Throwable $e): void
  8. {
  9. if (!class_exists(\NunoMaduro\Collision\Handler::class)) {
  10. dump($e);
  11. ConsoleOutputUtils::info("You can get better exception output by installing the library nunomaduro/collision.");
  12. return;
  13. }
  14. $output = new ConsoleOutput(OutputInterface::VERBOSITY_VERBOSE);
  15. try {
  16. $handler = new \NunoMaduro\Collision\Handler(new \NunoMaduro\Collision\Writer(null, $output));
  17. } catch (\Exception $e) {
  18. // Version 3 used a different API
  19. $handler = new \NunoMaduro\Collision\Handler(new \NunoMaduro\Collision\Writer($output));
  20. }
  21. $handler->setInspector(new \Whoops\Exception\Inspector($e));
  22. $handler->setException($e);
  23. $handler->handle();
  24. }
  25. }