[Box Backup-commit] COMMIT r3322 - box/trunk/lib/common

subversion at boxbackup.org subversion at boxbackup.org
Wed Apr 9 23:15:45 BST 2014


Author: chris
Date: 2014-04-09 23:15:45 +0100 (Wed, 09 Apr 2014)
New Revision: 3322

Modified:
   box/trunk/lib/common/MainHelper.h
Log:
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.

Modified: box/trunk/lib/common/MainHelper.h
===================================================================
--- box/trunk/lib/common/MainHelper.h	2014-04-09 22:15:42 UTC (rev 3321)
+++ box/trunk/lib/common/MainHelper.h	2014-04-09 22:15:45 UTC (rev 3322)
@@ -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; \
 	}




More information about the Boxbackup-commit mailing list