From 0a86525c9d59915cbc1ac27313af6432951a0dee Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 15 Dec 2023 02:38:40 +0000 Subject: [PATCH] Fixed error reporting in Hanyuu. --- hanyuu.php | 22 ++++------------------ public/index.php | 2 ++ 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/hanyuu.php b/hanyuu.php index 04348da..9a970a1 100644 --- a/hanyuu.php +++ b/hanyuu.php @@ -32,26 +32,12 @@ if($cfg->hasValues('sentry:dsn')) 'traces_sample_rate' => $cfg->getFloat('tracesRate', 0.2), 'profiles_sample_rate' => $cfg->getFloat('profilesRate', 0.2), ]); + + set_exception_handler(function(\Throwable $ex) { + \Sentry\captureException($ex); + }); })($cfg->scopeTo('sentry')); -set_exception_handler(function(\Throwable $ex) { - \Sentry\captureException($ex); - - if(HAU_CLI) - die((string)$ex); - - http_response_code(500); - ob_clean(); - - if(HAU_DEBUG) { - header('Content-Type: text/plain; charset=utf-8'); - die((string)$ex); - } - - header('Content-Type: text/html; charset-utf-8'); - die('

Hanyuu is sad.

'); -}); - $dbc = DbTools::create($cfg->getString('database:dsn', 'null')); $dbc->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';'); diff --git a/public/index.php b/public/index.php index 86381b1..ee50838 100644 --- a/public/index.php +++ b/public/index.php @@ -4,6 +4,8 @@ namespace Hanyuu; require_once __DIR__ . '/../hanyuu.php'; set_exception_handler(function(\Throwable $ex) { + \Sentry\captureException($ex); + http_response_code(500); ob_clean();