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,25 +32,11 @@ if($cfg->hasValues('sentry:dsn'))
'traces_sample_rate' => $cfg->getFloat('tracesRate', 0.2), 'traces_sample_rate' => $cfg->getFloat('tracesRate', 0.2),
'profiles_sample_rate' => $cfg->getFloat('profilesRate', 0.2), 'profiles_sample_rate' => $cfg->getFloat('profilesRate', 0.2),
]); ]);
})($cfg->scopeTo('sentry'));
set_exception_handler(function(\Throwable $ex) { set_exception_handler(function(\Throwable $ex) {
\Sentry\captureException($ex); \Sentry\captureException($ex);
});
if(HAU_CLI) })($cfg->scopeTo('sentry'));
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 = 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\';'); $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'; require_once __DIR__ . '/../hanyuu.php';
set_exception_handler(function(\Throwable $ex) { set_exception_handler(function(\Throwable $ex) {
\Sentry\captureException($ex);
http_response_code(500); http_response_code(500);
ob_clean(); ob_clean();