Skip to content

Commit

Permalink
Push as an ‘early task error’ instead of throwing exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Jul 13, 2023
1 parent 171c2e1 commit 6c3116b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Generator
protected $after;
protected $extraUrls;
protected $workers = 1;
protected $earlyTaskErrors = [];
protected $taskResults;
protected $disableClear = false;

Expand Down Expand Up @@ -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),
];
}

Expand Down Expand Up @@ -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, '*')) {
Expand All @@ -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[] = '<fg=red>[✘]</> '.URL::makeRelative($page->url()).' (Excluded in config/statamic/ssg.php)';
}

return $excluded;
Expand Down

0 comments on commit 6c3116b

Please sign in to comment.