mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 13:27:59 +03:00
feat(tokenizer): add exceptions
This commit is contained in:
@@ -59,6 +59,37 @@ namespace config
|
||||
void rollBackToken();
|
||||
void set_last(e_token type);
|
||||
|
||||
class NoMoreTokens: public std::exception
|
||||
{
|
||||
public:
|
||||
virtual const char *what() const throw()
|
||||
{
|
||||
return ("No more tokens!");
|
||||
}
|
||||
};
|
||||
class InvalidToken: public std::exception
|
||||
{
|
||||
protected:
|
||||
std::string *msg;
|
||||
|
||||
public:
|
||||
InvalidToken(const std::string &token)
|
||||
{
|
||||
|
||||
msg = new std::string("Invalid token: '" + token + "'");
|
||||
}
|
||||
|
||||
virtual const char *what() const throw()
|
||||
{
|
||||
return (msg->c_str());
|
||||
}
|
||||
|
||||
virtual ~InvalidToken() throw()
|
||||
{
|
||||
delete msg;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/* struct s_token Tokenizer::getKey(void) */
|
||||
|
||||
Reference in New Issue
Block a user