From 8609dee529cedea159cf06d7cf4021e90f7f6a7b Mon Sep 17 00:00:00 2001 From: whaffman Date: Thu, 30 Oct 2025 23:04:37 +0100 Subject: [PATCH] feat: add error handling for empty configuration files --- webserv/config/ConfigManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webserv/config/ConfigManager.cpp b/webserv/config/ConfigManager.cpp index 12563f1..ac91db6 100644 --- a/webserv/config/ConfigManager.cpp +++ b/webserv/config/ConfigManager.cpp @@ -50,6 +50,12 @@ void ConfigManager::parseConfigFile(const std::string &filePath) std::stringstream buffer; buffer << file.rdbuf(); std::string content = buffer.str(); + + if (content.empty()) + { + throw std::runtime_error("Config file is empty: " + filePath); + } + utils::removeComments(content); globalConfig_ = std::make_unique(content);