From 8dae25abc5de77ea302e5cc9d55d9bb01570d0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Tue, 8 Jun 2021 23:33:17 +0300 Subject: [PATCH] use report instead of logger --- app/Console/Commands/BillReminder.php | 7 +++---- app/Console/Commands/InvoiceReminder.php | 7 +++---- app/Console/Commands/RecurringCheck.php | 4 ++-- app/Http/Middleware/Money.php | 2 +- app/Listeners/Module/InstallExtraModules.php | 2 +- app/Listeners/Module/UpdateExtraModules.php | 2 +- app/Providers/App.php | 2 +- app/Traits/Currencies.php | 7 ++----- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/Console/Commands/BillReminder.php b/app/Console/Commands/BillReminder.php index a921a3311..65737d589 100644 --- a/app/Console/Commands/BillReminder.php +++ b/app/Console/Commands/BillReminder.php @@ -6,8 +6,7 @@ use App\Events\Document\DocumentReminded; use App\Models\Common\Company; use App\Models\Document\Document; use App\Notifications\Purchase\Bill as Notification; -use App\Utilities\Overrider; -use Date; +use App\Utilities\Date; use Illuminate\Console\Command; class BillReminder extends Command @@ -80,10 +79,10 @@ class BillReminder extends Command foreach ($bills as $bill) { try { event(new DocumentReminded($bill, Notification::class)); - } catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) { + } catch (\Throwable $e) { $this->error($e->getMessage()); - logger('Bill reminder:: ' . $e->getMessage()); + report($e); } } } diff --git a/app/Console/Commands/InvoiceReminder.php b/app/Console/Commands/InvoiceReminder.php index 25caccc53..e60113c5e 100644 --- a/app/Console/Commands/InvoiceReminder.php +++ b/app/Console/Commands/InvoiceReminder.php @@ -6,8 +6,7 @@ use App\Events\Document\DocumentReminded; use App\Models\Common\Company; use App\Models\Document\Document; use App\Notifications\Sale\Invoice as Notification; -use App\Utilities\Overrider; -use Date; +use App\Utilities\Date; use Illuminate\Console\Command; class InvoiceReminder extends Command @@ -80,10 +79,10 @@ class InvoiceReminder extends Command foreach ($invoices as $invoice) { try { event(new DocumentReminded($invoice, Notification::class)); - } catch (\Exception | \Throwable | \Swift_RfcComplianceException | \Illuminate\Database\QueryException $e) { + } catch (\Throwable $e) { $this->error($e->getMessage()); - logger('Invoice reminder:: ' . $e->getMessage()); + report($e); } } } diff --git a/app/Console/Commands/RecurringCheck.php b/app/Console/Commands/RecurringCheck.php index 3b683dd5c..2ea7704ce 100644 --- a/app/Console/Commands/RecurringCheck.php +++ b/app/Console/Commands/RecurringCheck.php @@ -162,10 +162,10 @@ class RecurringCheck extends Command try { return $this->$function($model, $schedule_date); - } catch (\Exception | \Throwable | \Swift_RfcComplianceException| \Swift_TransportException | \Illuminate\Database\QueryException $e) { + } catch (\Throwable $e) { $this->error($e->getMessage()); - logger('Recurring check:: ' . $e->getMessage()); + report($e); return false; } diff --git a/app/Http/Middleware/Money.php b/app/Http/Middleware/Money.php index 02411b933..4ec5f1350 100644 --- a/app/Http/Middleware/Money.php +++ b/app/Http/Middleware/Money.php @@ -95,7 +95,7 @@ class Money $amount = money($money_format, $currency_code)->getAmount(); } catch (InvalidArgumentException | OutOfBoundsException | UnexpectedValueException $e) { - logger($e->getMessage()); + report($e); $amount = 0; diff --git a/app/Listeners/Module/InstallExtraModules.php b/app/Listeners/Module/InstallExtraModules.php index 3af0a9695..ac5bd276d 100644 --- a/app/Listeners/Module/InstallExtraModules.php +++ b/app/Listeners/Module/InstallExtraModules.php @@ -53,7 +53,7 @@ class InstallExtraModules $this->dispatch(new InstallModule($alias, $event->company_id, $event->locale)); } catch (\Exception $e) { - logger($e->getMessage()); + report($e); // Stop the propagation of event if the required module failed to install return false; diff --git a/app/Listeners/Module/UpdateExtraModules.php b/app/Listeners/Module/UpdateExtraModules.php index 8e4a9fa81..73c5f2b3b 100644 --- a/app/Listeners/Module/UpdateExtraModules.php +++ b/app/Listeners/Module/UpdateExtraModules.php @@ -58,7 +58,7 @@ class UpdateExtraModules if (true !== $result = Console::run($command)) { $message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]); - logger($message); + report($message); // Stop the propagation of event if the required module failed to update return false; diff --git a/app/Providers/App.php b/app/Providers/App.php index 1cbc76bfb..3b02fbda5 100644 --- a/app/Providers/App.php +++ b/app/Providers/App.php @@ -42,7 +42,7 @@ class App extends Provider Model::handleLazyLoadingViolationUsing(function ($model, $relation) { $class = get_class($model); - logger("Attempted to lazy load [{$relation}] on model [{$class}]."); + report("Attempted to lazy load [{$relation}] on model [{$class}]."); }); } } diff --git a/app/Traits/Currencies.php b/app/Traits/Currencies.php index b7b07c036..0f7fd7eb7 100644 --- a/app/Traits/Currencies.php +++ b/app/Traits/Currencies.php @@ -3,9 +3,6 @@ namespace App\Traits; use Akaunting\Money\Money; -use InvalidArgumentException; -use OutOfBoundsException; -use UnexpectedValueException; trait Currencies { @@ -20,8 +17,8 @@ trait Currencies try { $money = $money->$method((double) $rate); - } catch (InvalidArgumentException | OutOfBoundsException | UnexpectedValueException $e) { - logger($e->getMessage()); + } catch (\Throwable $e) { + report($e); return 0; }