From dae9e6d09659a811c1c1d93548f3b501ff1deaf1 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 10 Oct 2023 15:18:37 -0700 Subject: [PATCH] Improve try catch blocks --- app/Listeners/CheckoutableListener.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 34d93550e..ec51130b1 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -42,7 +42,7 @@ class CheckoutableListener /** * Make a checkout acceptance and attach it in the notification */ - $acceptance = $this->getCheckoutAcceptance($event); + $acceptance = $this->getCheckoutAcceptance($event); try { if (! $event->checkedOutTo->locale) { @@ -61,12 +61,11 @@ class CheckoutableListener Notification::route('slack', Setting::getSettings()->webhook_endpoint) ->notify($this->getCheckoutNotification($event)); } - } catch (Exception $e) { - if ($e instanceof ClientException){ - Log::debug("Exception caught during checkout notification: ".$e->getMessage()); - return; - } - + } + catch (ClientException $e){ + Log::debug("Exception caught during checkout notification: ".$e->getMessage()); + } + catch (Exception $e) { Log::error("Exception caught during checkout notification: ".$e->getMessage()); } } @@ -115,12 +114,11 @@ class CheckoutableListener Notification::route('slack', Setting::getSettings()->webhook_endpoint) ->notify($this->getCheckinNotification($event)); } - } catch (Exception $e) { - if ($e instanceof ClientException){ - Log::debug("Exception caught during checkout notification: ".$e->getMessage()); - return; - } - + } + catch (ClientException $e){ + Log::debug("Exception caught during checkout notification: ".$e->getMessage()); + } + catch (Exception $e) { Log::error("Exception caught during checkin notification: ".$e->getMessage()); } }