Skip to content

Commit

Permalink
Rethrow exception about being unable to read file for placeholder gen…
Browse files Browse the repository at this point in the history
…eration in SSG context

Workaround: spatie#178 (comment)
  • Loading branch information
ncla committed Feb 11, 2023
1 parent 3c74106 commit 40d9f20
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Breakpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use Exception;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
use League\Flysystem\FilesystemException;
use Statamic\Contracts\Assets\Asset;
Expand Down Expand Up @@ -288,7 +290,10 @@ private function readImageToBase64($assetPath): string|null
$assetContent = $cache->read($assetPath);
$assetMimeType = $cache->mimeType($assetPath);
} catch (FilesystemException $e) {
if (config('app.debug')) {
$isSsgRunning = App::runningInConsole() &&
Str::startsWith(Arr::get(request()->server(), 'argv.1'), ['statamic:ssg:generate', 'ssg:generate']);

if (config('app.debug') || $isSsgRunning) {
throw $e;
}

Expand Down

0 comments on commit 40d9f20

Please sign in to comment.