|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace Knuckles\Scribe\Tools;
|
|
namespace Knuckles\Scribe\Tools;
|
|
|
|
|
|
|
|
+use Amp\MultiReasonException;
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
@@ -10,18 +11,28 @@ class ErrorHandlingUtils
|
|
public static function dumpExceptionIfVerbose(\Throwable $e, $completelySilent = false): void
|
|
public static function dumpExceptionIfVerbose(\Throwable $e, $completelySilent = false): void
|
|
{
|
|
{
|
|
if (Flags::$shouldBeVerbose) {
|
|
if (Flags::$shouldBeVerbose) {
|
|
- self::dumpException($e);
|
|
|
|
|
|
+ if ($e instanceof MultiReasonException) {
|
|
|
|
+ self::dumpException($e->getReasons()[0]);
|
|
|
|
+ } else {
|
|
|
|
+ self::dumpException($e);
|
|
|
|
+ }
|
|
} else if (!$completelySilent) {
|
|
} else if (!$completelySilent) {
|
|
- [$firstFrame, $secondFrame] = $e->getTrace();
|
|
|
|
|
|
+ if ($e instanceof MultiReasonException) {
|
|
|
|
+ $message = join("\n", array_map(function (\Throwable $reason) {
|
|
|
|
+ return $reason->getMessage();
|
|
|
|
+ }, $e->getReasons()));
|
|
|
|
+ } else {
|
|
|
|
+ [$firstFrame, $secondFrame] = $e->getTrace();
|
|
|
|
|
|
- try {
|
|
|
|
- ['file' => $file, 'line' => $line] = $firstFrame;
|
|
|
|
- } catch (\Exception $_) {
|
|
|
|
- ['file' => $file, 'line' => $line] = $secondFrame;
|
|
|
|
|
|
+ try {
|
|
|
|
+ ['file' => $file, 'line' => $line] = $firstFrame;
|
|
|
|
+ } catch (\Exception $_) {
|
|
|
|
+ ['file' => $file, 'line' => $line] = $secondFrame;
|
|
|
|
+ }
|
|
|
|
+ $exceptionType = get_class($e);
|
|
|
|
+ $message = $e->getMessage();
|
|
|
|
+ $message = "$exceptionType in $file at line $line: $message";
|
|
}
|
|
}
|
|
- $exceptionType = get_class($e);
|
|
|
|
- $message = $e->getMessage();
|
|
|
|
- $message = "$exceptionType in $file at line $line: $message";
|
|
|
|
ConsoleOutputUtils::warn($message);
|
|
ConsoleOutputUtils::warn($message);
|
|
ConsoleOutputUtils::warn('Run this again with the --verbose flag to see the full stack trace.');
|
|
ConsoleOutputUtils::warn('Run this again with the --verbose flag to see the full stack trace.');
|
|
}
|
|
}
|