summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/common/Box.h21
-rw-r--r--lib/common/Logging.h19
-rw-r--r--lib/common/Test.h1
3 files changed, 34 insertions, 7 deletions
diff --git a/lib/common/Box.h b/lib/common/Box.h
index 1124a062..77f7d1f4 100644
--- a/lib/common/Box.h
+++ b/lib/common/Box.h
@@ -103,18 +103,25 @@
#define THROW_EXCEPTION(type, subtype) \
{ \
- OPTIONAL_DO_BACKTRACE \
- BOX_WARNING("Exception thrown: " #type "(" #subtype ") " \
- "at " __FILE__ "(" << __LINE__ << ")") \
+ if(!HideExceptionMessageGuard::ExceptionsHidden()) \
+ { \
+ OPTIONAL_DO_BACKTRACE \
+ BOX_WARNING("Exception thrown: " \
+ #type "(" #subtype ") " \
+ "at " __FILE__ "(" << __LINE__ << ")") \
+ } \
throw type(type::subtype); \
}
#define THROW_EXCEPTION_MESSAGE(type, subtype, message) \
{ \
- OPTIONAL_DO_BACKTRACE \
- BOX_WARNING("Exception thrown: " #type "(" #subtype ") " \
- " (" message ") at " \
- __FILE__ "(" << __LINE__ << ")") \
+ if(!HideExceptionMessageGuard::ExceptionsHidden()) \
+ { \
+ OPTIONAL_DO_BACKTRACE \
+ BOX_WARNING("Exception thrown: " \
+ #type "(" #subtype ") (" message ") at " \
+ __FILE__ "(" << __LINE__ << ")") \
+ } \
throw type(type::subtype, message); \
}
diff --git a/lib/common/Logging.h b/lib/common/Logging.h
index 9bb2cf6c..35e14d83 100644
--- a/lib/common/Logging.h
+++ b/lib/common/Logging.h
@@ -320,4 +320,23 @@ class FileLogger : public Logger
virtual void SetProgramName(const std::string& rProgramName) { }
};
+class HideExceptionMessageGuard
+{
+ public:
+ HideExceptionMessageGuard()
+ {
+ mOldHiddenState = sHiddenState;
+ sHiddenState = true;
+ }
+ ~HideExceptionMessageGuard()
+ {
+ sHiddenState = mOldHiddenState;
+ }
+ static bool ExceptionsHidden() { return sHiddenState; }
+
+ private:
+ static bool sHiddenState;
+ bool mOldHiddenState;
+};
+
#endif // LOGGING__H
diff --git a/lib/common/Test.h b/lib/common/Test.h
index f96280c2..08ba4542 100644
--- a/lib/common/Test.h
+++ b/lib/common/Test.h
@@ -54,6 +54,7 @@ extern std::string bbackupd_args, bbstored_args, bbackupquery_args, test_args;
#define TEST_CHECK_THROWS(statement, excepttype, subtype) \
{ \
bool didthrow = false; \
+ HideExceptionMessageGuard hide; \
try \
{ \
statement; \