chore: add pause on end of application when in debug mode, improve exception handling

This commit is contained in:
TopchetoEU 2022-10-11 14:38:42 +03:00
parent 349bcc462c
commit ff6d01034a

View File

@ -141,6 +141,7 @@ int main(int argc, const char *argv[]) {
std::vector<std::string> files; std::vector<std::string> files;
messages::msg_stack_t msg_stack; messages::msg_stack_t msg_stack;
try {
options::parser_t parser; options::parser_t parser;
data::map_t conf; data::map_t conf;
add_flags(parser); add_flags(parser);
@ -153,19 +154,30 @@ int main(int argc, const char *argv[]) {
for (const auto &file : files) { for (const auto &file : files) {
std::ifstream f { file, std::ios_base::in }; std::ifstream f { file, std::ios_base::in };
try {
auto tokens = token_t::parse_many(msg_stack, lex::token_t::parse_file(msg_stack, file, f)); auto tokens = token_t::parse_many(msg_stack, lex::token_t::parse_file(msg_stack, file, f));
data::map_t ast; data::map_t ast;
if (!ast::ast_ctx_t::parse(msg_stack, tokens, ast)) continue; if (!ast::ast_ctx_t::parse(msg_stack, tokens, ast)) continue;
std::cout << data::json::stringify(ast) << std::endl; std::cout << data::json::stringify(ast) << std::endl;
} }
throw 15.0f;
}
catch (const messages::message_t &msg) { catch (const messages::message_t &msg) {
msg_stack.push(msg); msg_stack.push(msg);
} }
catch (const std::string &msg) {
msg_stack.push(message_t::error(msg));
}
catch (...) {
std::cout << std::endl;
msg_stack.push(message_t::error("A fatal error occurred."));
} }
msg_stack.print(std::cout, messages::message_t::DEBUG, true); msg_stack.print(std::cout, messages::message_t::DEBUG, true);
#ifdef PROFILE_debug
system("pause");
#endif
return 0; return 0;
} }