Skip to content

Commit

Permalink
add try/catch on update permanent cache via scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed May 15, 2024
1 parent b34aff3 commit 902639f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Commands/UpdatePermanentCachesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Vormkracht10\PermanentCache\Commands;

use Exception;
use Illuminate\Console\Command;
use Spatie\Emoji\Emoji;
use SplObjectStorage;
Expand Down Expand Up @@ -59,12 +60,19 @@ public function handle()
$cache = $caches->current();
$parameters = $caches->getInfo();

$cache->update($parameters);

$currentTask = $cache->getName();
$emoji = ($progressBar->getProgress() % 2 ? Emoji::hourglassNotDone() : Emoji::hourglassDone());

$progressBar->setMessage('Updating: '.$currentTask.' '.$emoji);

try {
$cache->update($parameters);
} catch (Exception $exception) {
$progressBar->setMessage('Error: '.$currentTask.' '.Emoji::warning());

sleep(2);
}

$progressBar->advance();
}

Expand Down

0 comments on commit 902639f

Please sign in to comment.