fix handling exceptions during sql transaction

This commit is contained in:
sheepish
2024-06-03 11:59:29 +00:00
committed by Spine
parent d79f9e338f
commit 1fe98bad27
2 changed files with 5 additions and 4 deletions

View File

@@ -155,8 +155,8 @@ class Debug {
);
}
public function saveError(\Exception $e): void {
$this->saveCase(
public function saveError(\Exception $e): int {
return $this->saveCase(
$e->getMessage() . "\n"
. str_replace(SERVER_ROOT . '/', '', $e->getTraceAsString())
);

View File

@@ -192,14 +192,15 @@ if (!$file || !preg_match('/^[a-z][a-z0-9_]+$/', $Document)) {
try {
require_once($file);
} catch (Gazelle\DB\MysqlException $e) {
Gazelle\DB::DB()->rollback(); // if there was an ongoing transaction, abort it
if (DEBUG_MODE || (isset($Viewer) && $Viewer->permitted('site_debug'))) {
echo $Twig->render('error-db.twig', [
'message' => $e->getMessage(),
'trace' => str_replace(SERVER_ROOT . '/', '', $e->getTraceAsString()),
]);
} else {
$Debug->saveError($e);
error("That is not supposed to happen, please send a Staff Message to \"Staff\" for investigation.");
$id = $Debug->saveError($e);
error("That is not supposed to happen, please create a thread in the Bugs forum explaining what you were doing and referencing Error ID $id");
}
} catch (\Exception $e) {
$Debug->saveError($e);