Skip to content

Commit 741074e

Browse files
committed
Handle errors in cache check
1 parent c4cbc5c commit 741074e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Checks/CacheConnection.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Bref\LaravelHealthCheck\CheckResult;
77
use Illuminate\Support\Facades\Cache;
88
use Illuminate\Support\Str;
9+
use Throwable;
910

1011
class CacheConnection extends Check
1112
{
@@ -16,8 +17,12 @@ public function getName(): string
1617

1718
public function check(): CheckResult
1819
{
19-
if (! $this->canWriteValuesToCache()) {
20-
return $this->error();
20+
try {
21+
if (! $this->canWriteValuesToCache()) {
22+
return $this->error();
23+
}
24+
} catch (Throwable $e) {
25+
return $this->error($e->getMessage());
2126
}
2227

2328
return $this->ok();

0 commit comments

Comments
 (0)