mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 14:03:34 +00:00
Merge pull request #385 from TheMatt2/error-handling
Clearer Error Message on Misconfiguration
This commit is contained in:
commit
179d44fdd3
@ -5,6 +5,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <bcrypt/BCrypt.hpp>
|
#include <bcrypt/BCrypt.hpp>
|
||||||
@ -77,9 +78,16 @@ int main(int argc, char** argv) {
|
|||||||
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
Game::logger->SetLogToConsole(bool(std::stoi(config.GetValue("log_to_console"))));
|
||||||
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
Game::logger->SetLogDebugStatements(config.GetValue("log_debug_statements") == "1");
|
||||||
|
|
||||||
|
//Check CDClient exists
|
||||||
|
const std::string cdclient_path = "./res/CDServer.sqlite";
|
||||||
|
if (!std::filesystem::is_regular_file(cdclient_path)) {
|
||||||
|
Game::logger->Log("WorldServer", "%s does not exist\n", cdclient_path.c_str());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//Connect to CDClient
|
//Connect to CDClient
|
||||||
try {
|
try {
|
||||||
CDClientDatabase::Connect("./res/CDServer.sqlite");
|
CDClientDatabase::Connect(cdclient_path);
|
||||||
} catch (CppSQLite3Exception& e) {
|
} catch (CppSQLite3Exception& e) {
|
||||||
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database\n");
|
Game::logger->Log("WorldServer", "Unable to connect to CDServer SQLite Database\n");
|
||||||
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
||||||
@ -87,7 +95,16 @@ int main(int argc, char** argv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get CDClient initial information
|
||||||
|
try {
|
||||||
CDClientManager::Instance()->Initialize();
|
CDClientManager::Instance()->Initialize();
|
||||||
|
} catch (CppSQLite3Exception& e) {
|
||||||
|
Game::logger->Log("WorldServer", "Failed to initialize CDServer SQLite Database\n");
|
||||||
|
Game::logger->Log("WorldServer", "May be caused by corrupted file: %s\n", cdclient_path.c_str());
|
||||||
|
Game::logger->Log("WorldServer", "Error: %s\n", e.errorMessage());
|
||||||
|
Game::logger->Log("WorldServer", "Error Code: %i\n", e.errorCode());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//Connect to the MySQL Database
|
//Connect to the MySQL Database
|
||||||
std::string mysql_host = config.GetValue("mysql_host");
|
std::string mysql_host = config.GetValue("mysql_host");
|
||||||
|
Loading…
Reference in New Issue
Block a user