aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2013-03-28 17:37:49 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2014-02-15 15:21:52 +0100
commitd374448af8ab690c810757f73ba44f208db96f30 (patch)
tree48e15c42d7a01b10aaef51d0113572ea53fec797 /src/main.cpp
parent6d4668bdaf393aa45d9adb640774f998c6b4aa58 (diff)
downloadsciteco-d374448af8ab690c810757f73ba44f208db96f30.tar.gz
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
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp37
1 files changed, 22 insertions, 15 deletions
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