From 9a15b3e3157068c3be87dca325abc52ece6e6ff1 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 9 Apr 2014 22:15:45 +0000 Subject: 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. --- lib/common/MainHelper.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib') 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; \ } -- cgit v1.2.3