From d3fe1b788dde2aa2c4bc66a5b40b3d28a3c85c95 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 8 Dec 2024 19:56:00 +0700 Subject: [PATCH] Updated --- library/config.php | 2 +- src/Dev.php | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/library/config.php b/library/config.php index 33910be9d..7fb327b88 100644 --- a/library/config.php +++ b/library/config.php @@ -462,7 +462,7 @@ $bb_cfg['adv_email'] = "adv@$domain_name"; // advertisement email // Error reporting $bb_cfg['whoops'] = [ - 'enabled' => true, + 'error_message' => 'Sorry, something went wrong. Drink coffee and come back after some time... ☕️', 'blacklist' => [ '_COOKIE' => array_keys($_COOKIE), '_SERVER' => array_keys($_SERVER), diff --git a/src/Dev.php b/src/Dev.php index 794deed90..b2e233235 100644 --- a/src/Dev.php +++ b/src/Dev.php @@ -47,8 +47,12 @@ class Dev $this->whoops = new Run; if (DBG_USER) { - $this->getWhoops(); + $this->getWhoopsOnPage(); + } else { + $this->getWhoopsPlaceholder(); } + $this->getWhoopsLogger(); + $this->getBugsnag(); $this->getTelegramSender(); @@ -97,14 +101,10 @@ class Dev * * @return void */ - private function getWhoops(): void + private function getWhoopsOnPage(): void { global $bb_cfg; - if (!$bb_cfg['whoops']['enabled']) { - return; - } - /** * Show errors on page */ @@ -127,7 +127,10 @@ class Dev ->setFormatter((new LineFormatter(null, null, true)))] ))); $this->whoops->pushHandler($loggingInConsole); + } + private function getWhoopsLogger(): void + { /** * Log errors in file */ @@ -143,6 +146,20 @@ class Dev } } + /** + * Whoops production debug driver + * + * @return void + */ + private function getWhoopsPlaceholder(): void + { + $this->whoops->pushHandler(function ($e) { + global $bb_cfg; + echo $bb_cfg['whoops']['error_message']; + echo "
Error: {$e->getMessage()}."; + }); + } + /** * Get SQL debug log *