From d374448af8ab690c810757f73ba44f208db96f30 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 28 Mar 2013 17:37:49 +0100 Subject: added support for TECO stack tracing * when an error is thrown, stack frames are collected on clean up, up to the toplevel macro * the toplevel macro decides how to display the error * now errors in interactive and batch mode are displayed differently * in batch mode, a backtrace is displayed as a sequence of messages * Execute::file() forwards errors correctly * the correct error in the file is displayed in interactive mode * necessary to build the stack trace --- src/main.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index ca3a37d..d0dfd84 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -254,26 +254,33 @@ main(int argc, char **argv) /* * Execute macro or mung file */ - if (eval_macro) { - try { - Execute::macro(eval_macro, false); - } catch (...) { - exit(EXIT_FAILURE); + try { + if (eval_macro) { + try { + Execute::macro(eval_macro, false); + } catch (State::Error &error) { + error.add_frame(new State::Error::ToplevelFrame()); + throw; /* forward */ + } + exit(EXIT_SUCCESS); } - exit(EXIT_SUCCESS); - } - if (g_file_test(mung_file, G_FILE_TEST_IS_REGULAR)) { - if (!Execute::file(mung_file, false)) - exit(EXIT_FAILURE); + if (g_file_test(mung_file, G_FILE_TEST_IS_REGULAR)) { + Execute::file(mung_file, false); - /* FIXME: make quit immediate in batch/macro mode (non-UNDO)? */ - if (quit_requested) { - /* FIXME */ - exit(EXIT_SUCCESS); + /* FIXME: make quit immediate in batch/macro mode (non-UNDO)? */ + if (quit_requested) { + /* FIXME */ + exit(EXIT_SUCCESS); + } } + g_free(mung_file); + } catch (State::Error &error) { + error.display_full(); + exit(EXIT_FAILURE); + } catch (...) { + exit(EXIT_FAILURE); } - g_free(mung_file); /* * If munged file didn't quit, switch into interactive mode -- cgit v1.2.3