From 741074e9fc8dc27e979a842d9019e827da7fcd60 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Sun, 3 Nov 2024 11:42:02 +0100 Subject: [PATCH] Handle errors in cache check --- src/Checks/CacheConnection.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Checks/CacheConnection.php b/src/Checks/CacheConnection.php index 970a927..e661d1c 100644 --- a/src/Checks/CacheConnection.php +++ b/src/Checks/CacheConnection.php @@ -6,6 +6,7 @@ use Bref\LaravelHealthCheck\CheckResult; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Str; +use Throwable; class CacheConnection extends Check { @@ -16,8 +17,12 @@ public function getName(): string public function check(): CheckResult { - if (! $this->canWriteValuesToCache()) { - return $this->error(); + try { + if (! $this->canWriteValuesToCache()) { + return $this->error(); + } + } catch (Throwable $e) { + return $this->error($e->getMessage()); } return $this->ok();