From 535697ac8838209e59e642b2b9f55330254a7374 Mon Sep 17 00:00:00 2001 From: Christian Taylor Date: Wed, 25 Sep 2024 14:45:21 -0500 Subject: [PATCH] Show exception messages in build output when fork is installed (#159) Co-authored-by: Jason Varga --- src/Generator.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 4278801..00026b9 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -199,8 +199,8 @@ protected function createContentFiles($urls = '*') $results = $this->tasks->run(...$closures); - if ($this->anyTasksFailed($results)) { - throw GenerationFailedException::withConsoleMessage("\x1B[1A\x1B[2K"); + if ($message = $this->firstFailedTask($results)) { + throw GenerationFailedException::withConsoleMessage("\x1B[1A\x1B[2K".$message); } $this->taskResults = $this->compileTasksResults($results); @@ -210,9 +210,9 @@ protected function createContentFiles($urls = '*') return $this; } - protected function anyTasksFailed($results) + protected function firstFailedTask($results) { - return collect($results)->contains(''); + return collect($results)->first(fn ($result) => is_string($result)); } protected function compileTasksResults(array $results) @@ -285,7 +285,7 @@ protected function makeContentGenerationClosures($pages, $request) $generated = $page->generate($request); } catch (NotGeneratedException $e) { if ($this->shouldFail($e)) { - throw GenerationFailedException::withConsoleMessage("\x1B[1A\x1B[2K".$e->consoleMessage()); + return $e->consoleMessage(); } $errors[] = $e->consoleMessage(); @@ -297,7 +297,7 @@ protected function makeContentGenerationClosures($pages, $request) if ($generated->hasWarning()) { if ($this->shouldFail($generated)) { - throw GenerationFailedException::withConsoleMessage($generated->consoleMessage()); + return $generated->consoleMessage(); } $warnings[] = $generated->consoleMessage();