upd: add except

This commit is contained in:
2023-11-06 22:04:47 +08:00
parent 6a7a957299
commit 86ea1176bf
2 changed files with 51 additions and 1 deletions

View File

@ -39,7 +39,26 @@ int main(int argc, char *argv[])
Python3Parser parser(&tokens);
tree::ParseTree *tree = parser.file_input();
EvalVisitor visitor;
visitor.visit(tree);
try
{
visitor.visit(tree);
}
catch (const InterpretException &e)
{
std::cerr << "[Interpret Error] " << e.what() << std::endl;
}
catch (const FatalError &e)
{
std::cerr << "\e[7m\e[31m[Fatal Error] " << e.what() << "\e[0m" << std::endl;
}
catch (const std::exception &e)
{
std::cerr << "\e[7m\e[31m[other std::exception] " << e.what() << "\e[0m" << std::endl;
}
catch (...)
{
std::cerr << "\e[7m\e[31m[Unknown Exception]\e[0m" << std::endl;
}
delete input_p;
return 0;
}