From 9b7f50cc044a161a9f0447326faa228563647635 Mon Sep 17 00:00:00 2001 From: Quinten Date: Tue, 14 Oct 2025 19:10:27 +0200 Subject: [PATCH] refactor(Client): improve error handling in request method and clean up includes --- webserv/client/Client.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/webserv/client/Client.cpp b/webserv/client/Client.cpp index 7a351eb..a460da7 100644 --- a/webserv/client/Client.cpp +++ b/webserv/client/Client.cpp @@ -1,12 +1,12 @@ #include - #include // for HttpHeaders #include // for Log, LOCATION #include // for Router #include // for Server #include // for Socket -#include // for uint8_t +#include // for uint8_t +#include #include // for ref, reference_wrapper #include // for map #include // for basic_string, to_string, operator+, operator<=> @@ -50,11 +50,11 @@ void Client::request() if (bytesRead < 0) { Log::error("Read error"); - return; + throw std::runtime_error("Read error"); } if (bytesRead == 0) { - Log::info("Client closed connection, fd: " + std::to_string(client_socket_->getFd())); // TODO weird + Log::info("Client closed connection, fd: " + std::to_string(client_socket_->getFd())); server_.disconnect(*this); // CRITICAL: RETURN IMMEDIATELY return; }