From 1899e4d1e8174bf41b73f0838fb8d533da79a411 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 15 Sep 2022 13:18:42 -0700 Subject: [PATCH] try/catch wrap notifications on checkin/checkout --- app/Listeners/CheckoutableListener.php | 52 +++++++++++++++----------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 71b131f40..9d6cd942b 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -20,6 +20,8 @@ use App\Notifications\CheckoutConsumableNotification; use App\Notifications\CheckoutLicenseNotification; use App\Notifications\CheckoutLicenseSeatNotification; use Illuminate\Support\Facades\Notification; +use Exception; +use Log; class CheckoutableListener { @@ -43,16 +45,20 @@ class CheckoutableListener */ $acceptance = $this->getCheckoutAcceptance($event); - if (! $event->checkedOutTo->locale) { - Notification::locale(Setting::getSettings()->locale)->send( - $this->getNotifiables($event), - $this->getCheckoutNotification($event, $acceptance) - ); - } else { - Notification::send( - $this->getNotifiables($event), - $this->getCheckoutNotification($event, $acceptance) - ); + try { + if (! $event->checkedOutTo->locale) { + Notification::locale(Setting::getSettings()->locale)->send( + $this->getNotifiables($event), + $this->getCheckoutNotification($event, $acceptance) + ); + } else { + Notification::send( + $this->getNotifiables($event), + $this->getCheckoutNotification($event, $acceptance) + ); + } + } catch (Exception $e) { + Log::error("Exception caught during checkout notification: ".$e->getMessage()); } } @@ -83,17 +89,21 @@ class CheckoutableListener } } - // Use default locale - if (! $event->checkedOutTo->locale) { - Notification::locale(Setting::getSettings()->locale)->send( - $this->getNotifiables($event), - $this->getCheckinNotification($event) - ); - } else { - Notification::send( - $this->getNotifiables($event), - $this->getCheckinNotification($event) - ); + try { + // Use default locale + if (! $event->checkedOutTo->locale) { + Notification::locale(Setting::getSettings()->locale)->send( + $this->getNotifiables($event), + $this->getCheckinNotification($event) + ); + } else { + Notification::send( + $this->getNotifiables($event), + $this->getCheckinNotification($event) + ); + } + } catch (Exception $e) { + Log::error("Exception caught during checkin notification: ".$e->getMessage()); } }