From cb06f3dcb6e554352a5e3f35c5d761f4a1e759d4 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 14 Jan 2024 13:02:16 +1100 Subject: [PATCH] Catch exception when trying to connect to update server --- app/Http/Middleware/CheckUpdate.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Http/Middleware/CheckUpdate.php b/app/Http/Middleware/CheckUpdate.php index 61e390e..725d599 100644 --- a/app/Http/Middleware/CheckUpdate.php +++ b/app/Http/Middleware/CheckUpdate.php @@ -39,14 +39,20 @@ class CheckUpdate $client = new Client; - $response = $client->request('POST',sprintf('%s/%s',self::UPDATE_SERVER,strtolower(config('app.version')))); + try { - if ($response->getStatusCode() === 200) { - $result = json_decode($response->getBody()); + $response = $client->request('POST',sprintf('%s/%s',self::UPDATE_SERVER,strtolower(config('app.version')))); - Log::debug(sprintf('CU_:- Update server returned...'),['update'=>$result]); + if ($response->getStatusCode() === 200) { + $result = json_decode($response->getBody()); - return $result; + Log::debug(sprintf('CU_:- Update server returned...'),['update'=>$result]); + + return $result; + } + + } catch (\Exception $e) { + Log::debug(sprintf('CU_:- Exception connecting to update server'),['e'=>get_class($e)]); } return NULL;