From 2863c9a657fdc3f677dd0e9794b5d791d524e6d5 Mon Sep 17 00:00:00 2001 From: Martin Folkerts Date: Mon, 2 Sep 2024 11:51:12 +0200 Subject: [PATCH] added a failed status when empty mosaic is create; --- laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php b/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php index 8956765..d7e59da 100644 --- a/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php +++ b/laravel_app/app/Jobs/ProjectMosiacGeneratorJob.php @@ -65,6 +65,7 @@ public function handle(): void ->env(['PATH' => $currentPath.':/usr/local/Cellar/pandoc/3.1.8/bin/pandoc']) ->start($command, function (string $type, string $output) use ($project) { ProjectLogger::log($project, $output); + $this->throwIfOutputContainsError($output); }); $results = $process->wait(); if ($results->successful()) { @@ -112,4 +113,12 @@ public static function handleFor(Project $project, Carbon $endDate, int $offset) ]); return new self($mosaic); } + + private function throwIfOutputContainsError(string $output) + { + if (str_contains($output, 'No images available this week, empty mosaic created')) { + throw new \RuntimeException( $output); + } + return true; + } }