Fixed error reporting in Hanyuu.

This commit is contained in:
flash 2023-12-15 02:38:40 +00:00
parent 67d86e4d0b
commit 0a86525c9d
2 changed files with 6 additions and 18 deletions

View file

@ -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('<h2>Hanyuu is sad.</h2>');
});
$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\';');

View file

@ -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();