catch errors

This commit is contained in:
Denis Duliçi 2020-07-10 13:37:48 +03:00
parent a2bd4758ad
commit 0c061a01ea
3 changed files with 23 additions and 5 deletions

View File

@ -78,8 +78,13 @@ class BillReminder extends Command
$bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor(); $bills = Bill::with('contact')->accrued()->notPaid()->due($date)->cursor();
foreach ($bills as $bill) { 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());
}
} }
} }
} }

View File

@ -78,7 +78,13 @@ class InvoiceReminder extends Command
$invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor(); $invoices = Invoice::with('contact')->accrued()->notPaid()->due($date)->cursor();
foreach ($invoices as $invoice) { 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());
}
} }
} }
} }

View File

@ -145,8 +145,15 @@ class RecurringCheck extends Command
$model->cloneable_relations = ['items', 'totals']; $model->cloneable_relations = ['items', 'totals'];
// Create new record try {
$clone = $model->duplicate(); $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 // Set original model id
$clone->parent_id = $model->id; $clone->parent_id = $model->id;