feat: add error handling for empty configuration files

This commit is contained in:
whaffman 2025-10-30 23:04:37 +01:00
parent d8fb7d0846
commit 8609dee529

View File

@ -50,6 +50,12 @@ void ConfigManager::parseConfigFile(const std::string &filePath)
std::stringstream buffer; std::stringstream buffer;
buffer << file.rdbuf(); buffer << file.rdbuf();
std::string content = buffer.str(); std::string content = buffer.str();
if (content.empty())
{
throw std::runtime_error("Config file is empty: " + filePath);
}
utils::removeComments(content); utils::removeComments(content);
globalConfig_ = std::make_unique<GlobalConfig>(content); globalConfig_ = std::make_unique<GlobalConfig>(content);