This commit is contained in:
Roman Kelesidis 2024-12-08 19:56:00 +07:00
commit d3fe1b788d
2 changed files with 24 additions and 7 deletions

View file

@ -462,7 +462,7 @@ $bb_cfg['adv_email'] = "adv@$domain_name"; // advertisement email
// Error reporting // Error reporting
$bb_cfg['whoops'] = [ $bb_cfg['whoops'] = [
'enabled' => true, 'error_message' => 'Sorry, something went wrong. Drink coffee and come back after some time... ☕️',
'blacklist' => [ 'blacklist' => [
'_COOKIE' => array_keys($_COOKIE), '_COOKIE' => array_keys($_COOKIE),
'_SERVER' => array_keys($_SERVER), '_SERVER' => array_keys($_SERVER),

View file

@ -47,8 +47,12 @@ class Dev
$this->whoops = new Run; $this->whoops = new Run;
if (DBG_USER) { if (DBG_USER) {
$this->getWhoops(); $this->getWhoopsOnPage();
} else {
$this->getWhoopsPlaceholder();
} }
$this->getWhoopsLogger();
$this->getBugsnag(); $this->getBugsnag();
$this->getTelegramSender(); $this->getTelegramSender();
@ -97,14 +101,10 @@ class Dev
* *
* @return void * @return void
*/ */
private function getWhoops(): void private function getWhoopsOnPage(): void
{ {
global $bb_cfg; global $bb_cfg;
if (!$bb_cfg['whoops']['enabled']) {
return;
}
/** /**
* Show errors on page * Show errors on page
*/ */
@ -127,7 +127,10 @@ class Dev
->setFormatter((new LineFormatter(null, null, true)))] ->setFormatter((new LineFormatter(null, null, true)))]
))); )));
$this->whoops->pushHandler($loggingInConsole); $this->whoops->pushHandler($loggingInConsole);
}
private function getWhoopsLogger(): void
{
/** /**
* Log errors in file * 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 "<hr>Error: {$e->getMessage()}.";
});
}
/** /**
* Get SQL debug log * Get SQL debug log
* *