mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
feat: catch exceptions in readConfig
This commit is contained in:
@@ -36,8 +36,30 @@ void Server::print_epoll_events(unsigned int events)
|
||||
//----------------------------------------------Configuration-----------------------------------------------------------------------------------
|
||||
void Server::readConfig(char *filename)
|
||||
{
|
||||
TOMLMap *root = parse(filename);
|
||||
TOMLMap *root = NULL;
|
||||
try
|
||||
{
|
||||
root = parse(filename);
|
||||
|
||||
}
|
||||
catch (config::Tokenizer::NoMoreTokens &e)
|
||||
{
|
||||
std::cerr << RED << "FATAL: ";
|
||||
std::cerr << e.what() << RESET << std::endl;
|
||||
// root->clear();
|
||||
// delete root;
|
||||
// clean_parsed(root);
|
||||
return;
|
||||
}
|
||||
catch (config::Tokenizer::InvalidToken &e)
|
||||
{
|
||||
std::cerr << RED << "FATAL: ";
|
||||
std::cerr << e.what() << RESET << std::endl;
|
||||
// clean_parsed(root);
|
||||
// root->clear();
|
||||
delete root;
|
||||
return;
|
||||
}
|
||||
|
||||
/* TOMLMap *map; */
|
||||
TOMLMap::iterator it1;
|
||||
@@ -408,9 +430,9 @@ void Server::clean_parsed(TOMLMap *root)
|
||||
DBOUT << ">>> cleaning up: <<<" << std::endl;
|
||||
for (it = root->begin(); it != root->end(); ++it)
|
||||
{
|
||||
/* DBOUT << RED << it->first */
|
||||
/* << ": " << GREEN */
|
||||
/* << *(it->second->toString()); */
|
||||
DBOUT << RED << it->first
|
||||
<< ": " << GREEN
|
||||
<< *(it->second->toString());
|
||||
|
||||
clean_generic(it->second);
|
||||
/* delete it->second; */
|
||||
|
||||
Reference in New Issue
Block a user