From 340de87643755061f2f069e90e30bb5cdf883286 Mon Sep 17 00:00:00 2001 From: adjoly Date: Mon, 23 Jun 2025 20:42:50 +0200 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=94=A8=E3=80=8D=20fix:=20fixed?= =?UTF-8?q?=20some=20things.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/config/Server.hpp | 4 +++- lib/tomlpp | 2 +- sample.toml | 1 + src/config/Config.cpp | 7 +++++-- src/main.cpp | 6 ++++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/includes/config/Server.hpp b/includes/config/Server.hpp index c701c5e..ab4a6f7 100644 --- a/includes/config/Server.hpp +++ b/includes/config/Server.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */ -/* Updated: 2025/05/03 09:42:27 by adjoly ### ########.fr */ +/* Updated: 2025/06/23 20:10:48 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -35,6 +35,8 @@ class Server { * @param The http error code for the page */ std::string getErrorPage(int page) { + if (_err_pages == not_nullptr) + return ""; if (_err_pages->find(page) != _err_pages->end()) return (*_err_pages)[page]; else diff --git a/lib/tomlpp b/lib/tomlpp index 9926aa1..9f3aa94 160000 --- a/lib/tomlpp +++ b/lib/tomlpp @@ -1 +1 @@ -Subproject commit 9926aa1530c08923d092df755fd5c876e56a409c +Subproject commit 9f3aa94aeb7fbe54518d7431c5ec35e66ecc7741 diff --git a/sample.toml b/sample.toml index 3f86598..933dad8 100644 --- a/sample.toml +++ b/sample.toml @@ -3,3 +3,4 @@ host = "0.0.0.0" port = 8090 [server.location./] +methods = {"GET" diff --git a/src/config/Config.cpp b/src/config/Config.cpp index 9555a37..3654b97 100644 --- a/src/config/Config.cpp +++ b/src/config/Config.cpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/14 12:53:54 by adjoly #+# #+# */ -/* Updated: 2025/05/03 09:42:44 by adjoly ### ########.fr */ +/* Updated: 2025/06/23 20:36:47 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,6 +16,7 @@ #include "node/default.hpp" #include "webserv.hpp" #include +#include #include #include @@ -26,7 +27,9 @@ Config::Config(std::string &filename) { try { file->parse(); - } catch (std::runtime_error &e) { + } catch (std::exception &e) { + // if (file->getParsedFile() != not_nullptr) + // delete file->getParsedFile(); delete file; throw e; } diff --git a/src/main.cpp b/src/main.cpp index 59d9027..2361b93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,7 +6,7 @@ /* By: mmoussou