Skip to content

Commit

Permalink
Show exception messages in build output when fork is installed (#159)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
imacrayon and jasonvarga authored Sep 25, 2024
1 parent 703db85 commit 535697a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down

0 comments on commit 535697a

Please sign in to comment.