🔨」 fix: fixed error with config and handled properly exception

This commit is contained in:
2025-05-01 16:32:44 +02:00
parent 040043694e
commit 9a28e15af0
8 changed files with 105 additions and 32 deletions

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */
/* Updated: 2025/05/01 12:48:12 by adjoly ### ########.fr */
/* Updated: 2025/05/01 15:29:53 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -28,18 +28,21 @@ class Config {
Logger *getLogger(void) { return _log; }
Server *getDefaultServer(void) const { return _default; }
std::vector<Server *> getServers(void) { return _servers; }
Server *getServer(size_t i) {
try {
Server *srv = _servers.at(i);
return srv;
} catch (std::out_of_range &e) {
return not_nullptr;
}
try {
Server *srv = _servers.at(i);
return srv;
} catch (std::out_of_range &e) {
return not_nullptr;
}
}
private:
std::vector<Server *> _servers;
Server *_default;
};
}; // namespace config

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
/* Updated: 2025/04/30 17:10:53 by adjoly ### ########.fr */
/* Updated: 2025/05/01 15:32:31 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -25,6 +25,7 @@ namespace config {
class Server {
public:
Server(toml::ANode *);
Server(toml::ANode *, void *);
~Server();
/**