From 0c061a01eaca723cc29bf87979d2ebaa2096a134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Fri, 10 Jul 2020 13:37:48 +0300 Subject: [PATCH] catch errors --- app/Console/Commands/BillReminder.php | 9 +++++++-- app/Console/Commands/InvoiceReminder.php | 8 +++++++- app/Console/Commands/RecurringCheck.php | 11 +++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/BillReminder.php b/app/Console/Commands/BillReminder.php index 13caf2a93..69cc3075a 100644 --- a/app/Console/Commands/BillReminder.php +++ b/app/Console/Commands/BillReminder.php @@ -78,8 +78,13 @@ class BillReminder extends Command $bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor(); foreach ($bills as $bill) { - event(new BillReminded($bill)); - + try { + event(new BillReminded($bill)); + } catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) { + $this->error($e->getMessage()); + + logger('Bill reminder:: ' . $e->getMessage()); + } } } } diff --git a/app/Console/Commands/InvoiceReminder.php b/app/Console/Commands/InvoiceReminder.php index 9f6d6af7e..d59aa8171 100644 --- a/app/Console/Commands/InvoiceReminder.php +++ b/app/Console/Commands/InvoiceReminder.php @@ -78,7 +78,13 @@ class InvoiceReminder extends Command $invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor(); foreach ($invoices as $invoice) { - event(new InvoiceReminded($invoice)); + try { + event(new InvoiceReminded($invoice)); + } catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) { + $this->error($e->getMessage()); + + logger('Invoice reminder:: ' . $e->getMessage()); + } } } } diff --git a/app/Console/Commands/RecurringCheck.php b/app/Console/Commands/RecurringCheck.php index cf99bd0af..e69ef3c74 100644 --- a/app/Console/Commands/RecurringCheck.php +++ b/app/Console/Commands/RecurringCheck.php @@ -145,8 +145,15 @@ class RecurringCheck extends Command $model->cloneable_relations = ['items', 'totals']; - // Create new record - $clone = $model->duplicate(); + try { + $clone = $model->duplicate(); + } catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) { + $this->error($e->getMessage()); + + logger('Recurring check:: ' . $e->getMessage()); + + return false; + } // Set original model id $clone->parent_id = $model->id;