diff options
author | Chris Wilson <chris+github@qwirx.com> | 2014-04-09 22:15:45 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2014-04-09 22:15:45 +0000 |
commit | 9a15b3e3157068c3be87dca325abc52ece6e6ff1 (patch) | |
tree | 6ce3397864f73ab37f49efe72d8c908bce08dc33 /lib/common | |
parent | 08a32e134b12529fd3ba5acacacf09113d3d0a9b (diff) |
Improve error message when fatal exception aborts a command-line tool.
Report the exception message details if it's a BoxException, so it's more
user friendly.
Diffstat (limited to 'lib/common')
-rw-r--r-- | lib/common/MainHelper.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/common/MainHelper.h b/lib/common/MainHelper.h index 3c6e9ff0..0303090e 100644 --- a/lib/common/MainHelper.h +++ b/lib/common/MainHelper.h @@ -19,18 +19,21 @@ #include "BoxException.h" #include "Logging.h" -#define MAINHELPER_START \ - if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ - { printf(BOX_VERSION "\n"); return 0; } \ +#define MAINHELPER_START \ + if(argc == 2 && ::strcmp(argv[1], "--version") == 0) \ + { printf(BOX_VERSION "\n"); return 0; } \ MEMLEAKFINDER_INIT \ - MEMLEAKFINDER_START \ + MEMLEAKFINDER_START \ try { -#define MAINHELPER_END \ - } catch(std::exception &e) { \ +#define MAINHELPER_END \ + } catch(BoxException &e) { \ + BOX_FATAL(e.what() << ": " << e.GetMessage()); \ + return 1; \ + } catch(std::exception &e) { \ BOX_FATAL(e.what()); \ - return 1; \ - } catch(...) { \ + return 1; \ + } catch(...) { \ BOX_FATAL("UNKNOWN"); \ return 1; \ } |