From 5e95bbd0e90a0e3f317a2718a3a8676663ff5370 Mon Sep 17 00:00:00 2001 From: Fady Mondy Date: Mon, 1 Apr 2024 01:01:26 +0200 Subject: [PATCH] add option to stop discord error log --- bootstrap/app.php | 18 ++++++++++-------- config/services.php | 1 + 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 4e2ba78..fd88861 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -22,14 +22,16 @@ ->withExceptions(function (Exceptions $exceptions) { $exceptions->renderable(\ProtoneMedia\Splade\SpladeCore::exceptionHandler($exceptions->handler)); $exceptions->reportable(function (Throwable $e) { - try { - $user = User::first(); - $user->notifyDiscord( - title: "================= ERROR ================= \n".'MESSAGE: '.$e->getMessage() . ' | FILE: '.$e->getFile().' | LINE: '.$e->getLine().' | URL: ' . url()->current(), - webhook: config('services.discord.error-webhook') - ); - }catch (\Exception $exception){ - // do nothing + if(config('services.discord.error-webhook-active')){ + try { + $user = User::first(); + $user->notifyDiscord( + title: "================= ERROR ================= \n".'MESSAGE: '.$e->getMessage() . ' | FILE: '.$e->getFile().' | LINE: '.$e->getLine().' | URL: ' . url()->current(), + webhook: config('services.discord.error-webhook') + ); + }catch (\Exception $exception){ + // do nothing + } } }); diff --git a/config/services.php b/config/services.php index d1efc01..399ee21 100644 --- a/config/services.php +++ b/config/services.php @@ -33,6 +33,7 @@ 'discord' => [ 'error-webhook' => env('DISCORD_ERROR_WEBHOOK'), + 'error-webhook-active' => env('DISCORD_ERROR_WEBHOOK_ACTIVE'), 'notification-webhook' => env('DISCORD_NOTIFICATION_WEBHOOK'), 'client_id' => env('DISCORD_CLIENT_ID'), 'client_secret' => env('DISCORD_CLIENT_SECRET'),