update exception catching

This commit is contained in:
David Markowitz 2024-12-03 22:41:56 -08:00
parent a7ca72dbbe
commit c42b57ba86
7 changed files with 12 additions and 12 deletions

View File

@ -60,7 +60,7 @@ int main(int argc, char** argv) {
try { try {
Database::Connect(); Database::Connect();
} catch (sql::SQLException& ex) { } catch (std::exception& ex) {
LOG("Got an error while connecting to the database: %s", ex.what()); LOG("Got an error while connecting to the database: %s", ex.what());
Database::Destroy("AuthServer"); Database::Destroy("AuthServer");
delete Game::server; delete Game::server;

View File

@ -81,7 +81,7 @@ int main(int argc, char** argv) {
//Connect to the MySQL Database //Connect to the MySQL Database
try { try {
Database::Connect(); Database::Connect();
} catch (sql::SQLException& ex) { } catch (std::exception& ex) {
LOG("Got an error while connecting to the database: %s", ex.what()); LOG("Got an error while connecting to the database: %s", ex.what());
Database::Destroy("ChatServer"); Database::Destroy("ChatServer");
delete Game::server; delete Game::server;

View File

@ -123,7 +123,7 @@ uint32_t BrickByBrickFix::UpdateBrickByBrickModelsToSd0() {
Database::Get()->UpdateUgcModelData(model.id, outputStringStream); Database::Get()->UpdateUgcModelData(model.id, outputStringStream);
LOG("Updated model %i to sd0", model.id); LOG("Updated model %i to sd0", model.id);
updatedModels++; updatedModels++;
} catch (sql::SQLException exception) { } catch (std::exception& exception) {
LOG("Failed to update model %i. This model should be inspected manually to see why." LOG("Failed to update model %i. This model should be inspected manually to see why."
"The database error is %s", model.id, exception.what()); "The database error is %s", model.id, exception.what());
} }

View File

@ -34,7 +34,7 @@ Migration LoadMigration(std::string path) {
void MigrationRunner::RunMigrations() { void MigrationRunner::RunMigrations() {
Database::Get()->CreateMigrationHistoryTable(); Database::Get()->CreateMigrationHistoryTable();
sql::SQLString finalSQL = ""; std::string finalSQL = "";
bool runSd0Migrations = false; bool runSd0Migrations = false;
for (const auto& entry : GeneralUtils::GetSqlFileNamesFromFolder((BinaryPathFinder::GetBinaryDir() / "./migrations/dlu/").string())) { for (const auto& entry : GeneralUtils::GetSqlFileNamesFromFolder((BinaryPathFinder::GetBinaryDir() / "./migrations/dlu/").string())) {
auto migration = LoadMigration("dlu/" + entry); auto migration = LoadMigration("dlu/" + entry);
@ -61,12 +61,12 @@ void MigrationRunner::RunMigrations() {
} }
if (!finalSQL.empty()) { if (!finalSQL.empty()) {
auto migration = GeneralUtils::SplitString(static_cast<std::string>(finalSQL), ';'); auto migration = GeneralUtils::SplitString(finalSQL, ';');
for (auto& query : migration) { for (auto& query : migration) {
try { try {
if (query.empty()) continue; if (query.empty()) continue;
Database::Get()->ExecuteCustomQuery(query.c_str()); Database::Get()->ExecuteCustomQuery(query);
} catch (sql::SQLException& e) { } catch (std::exception& e) {
LOG("Encountered error running migration: %s", e.what()); LOG("Encountered error running migration: %s", e.what());
} }
} }

View File

@ -103,7 +103,7 @@ int main(int argc, char** argv) {
//Connect to the MySQL Database //Connect to the MySQL Database
try { try {
Database::Connect(); Database::Connect();
} catch (sql::SQLException& ex) { } catch (std::exception& ex) {
LOG("Got an error while connecting to the database: %s", ex.what()); LOG("Got an error while connecting to the database: %s", ex.what());
LOG("Migrations not run"); LOG("Migrations not run");
return EXIT_FAILURE; return EXIT_FAILURE;
@ -264,7 +264,7 @@ int main(int argc, char** argv) {
//Create account //Create account
try { try {
Database::Get()->InsertNewAccount(username, std::string(hash, BCRYPT_HASHSIZE)); Database::Get()->InsertNewAccount(username, std::string(hash, BCRYPT_HASHSIZE));
} catch (sql::SQLException& e) { } catch (std::exception& e) {
LOG("A SQL error occurred!:\n %s", e.what()); LOG("A SQL error occurred!:\n %s", e.what());
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -24,9 +24,9 @@ void PersistentIDManager::Initialize() {
LOG("Invalid persistent object ID in database. Aborting to prevent bad id generation."); LOG("Invalid persistent object ID in database. Aborting to prevent bad id generation.");
throw std::runtime_error("Invalid persistent object ID in database. Aborting to prevent bad id generation."); throw std::runtime_error("Invalid persistent object ID in database. Aborting to prevent bad id generation.");
} }
} catch (sql::SQLException& e) { } catch (std::exception& e) {
LOG("Unable to fetch max persistent object ID in use. This will cause issues. Aborting to prevent collisions."); LOG("Unable to fetch max persistent object ID in use. This will cause issues. Aborting to prevent collisions.");
LOG("SQL error: %s", e.what()); LOG("Error: %s", e.what());
throw e; throw e;
} }
} }

View File

@ -194,7 +194,7 @@ int main(int argc, char** argv) {
//Connect to the MySQL Database: //Connect to the MySQL Database:
try { try {
Database::Connect(); Database::Connect();
} catch (sql::SQLException& ex) { } catch (std::exception& ex) {
LOG("Got an error while connecting to the database: %s", ex.what()); LOG("Got an error while connecting to the database: %s", ex.what());
return EXIT_FAILURE; return EXIT_FAILURE;
} }