From 6c3116b2811c98012a5f7eebbaebcc043aece675 Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Thu, 13 Jul 2023 16:53:30 -0400 Subject: [PATCH] =?UTF-8?q?Push=20as=20an=20=E2=80=98early=20task=20error?= =?UTF-8?q?=E2=80=99=20instead=20of=20throwing=20exception.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Generator.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 0794c9f..04b0f5e 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -35,6 +35,7 @@ class Generator protected $after; protected $extraUrls; protected $workers = 1; + protected $earlyTaskErrors = []; protected $taskResults; protected $disableClear = false; @@ -219,9 +220,9 @@ protected function compileTasksResults(array $results) $results = collect($results); return [ - 'count' => $results->sum('count'), + 'count' => count($this->earlyTaskErrors) + $results->sum('count'), 'warnings' => $results->flatMap->warnings, - 'errors' => $results->flatMap->errors, + 'errors' => collect($this->earlyTaskErrors)->merge($results->flatMap->errors), ]; } @@ -459,7 +460,7 @@ protected function makeAbsoluteUrl($url) return URL::tidy(Str::start($url, $this->config['base_url'].'/')); } - protected function shouldRejectPage($page, $throw = false) + protected function shouldRejectPage($page, $outputError = false) { foreach ($this->config['exclude'] as $url) { if (Str::endsWith($url, '*')) { @@ -471,10 +472,8 @@ protected function shouldRejectPage($page, $throw = false) $excluded = in_array($page->url(), $this->config['exclude']); - if ($excluded && $throw) { - throw GenerationFailedException::withConsoleMessage( - $page->url().' is configured to be excluded in [config/statamic/ssg.php]' - ); + if ($excluded && $outputError) { + $this->earlyTaskErrors[] = '[✘] '.URL::makeRelative($page->url()).' (Excluded in config/statamic/ssg.php)'; } return $excluded;