From 206a2711424469d5a0f91d0618cfb2c2c7437fd7 Mon Sep 17 00:00:00 2001 From: whaffman Date: Fri, 31 Oct 2025 10:05:03 +0100 Subject: [PATCH] feat: add error handling for empty directive arguments in createDirective method --- webserv/config/directive/DirectiveFactory.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/webserv/config/directive/DirectiveFactory.cpp b/webserv/config/directive/DirectiveFactory.cpp index 9976bcc..042bcbe 100644 --- a/webserv/config/directive/DirectiveFactory.cpp +++ b/webserv/config/directive/DirectiveFactory.cpp @@ -33,12 +33,16 @@ std::unique_ptr DirectiveFactory::createDirective(const std::string } } + if (arg.empty()) + { + throw std::invalid_argument("Directive argument is empty: " + name); + } if (type.empty()) { throw std::invalid_argument("Unsupported directive: " + name); } - Log::debug("Creating directive of type: " + std::string(type) + " with name: " + name + " and arg: " + arg); + Log::debug("Creating directive of type: " + std::string(type) + " with name: " + name + " and arg: |" + arg + "|"); return create(type, name, arg); }