[Box Backup-commit] COMMIT r2398 - box/trunk/lib/common
boxbackup-dev@boxbackup.org
boxbackup-dev@boxbackup.org
Fri, 5 Dec 2008 20:32:09 +0000 (GMT)
Author: chris
Date: 2008-12-05 20:32:09 +0000 (Fri, 05 Dec 2008)
New Revision: 2398
Modified:
box/trunk/lib/common/Box.h
Log:
Reformat ASSERT macro for readability.
Reformat THROW_EXCEPTION macro to avoid overlong lines.
Add THROW_EXCEPTION_MESSAGE macro to allow throwing an exception with
a message, such as the file name that caused the exception.
Modified: box/trunk/lib/common/Box.h
===================================================================
--- box/trunk/lib/common/Box.h 2008-12-05 20:30:07 UTC (rev 2397)
+++ box/trunk/lib/common/Box.h 2008-12-05 20:32:09 UTC (rev 2398)
@@ -42,7 +42,15 @@
extern bool AssertFailuresToSyslog;
#define ASSERT_FAILS_TO_SYSLOG_ON {AssertFailuresToSyslog = true;}
void BoxDebugAssertFailed(const char *cond, const char *file, int line);
- #define ASSERT(cond) {if(!(cond)) {BoxDebugAssertFailed(#cond, __FILE__, __LINE__); THROW_EXCEPTION(CommonException, AssertFailed)}}
+ #define ASSERT(cond) \
+ { \
+ if(!(cond)) \
+ { \
+ BoxDebugAssertFailed(#cond, __FILE__, __LINE__); \
+ THROW_EXCEPTION_MESSAGE(CommonException, \
+ AssertFailed, #cond); \
+ } \
+ }
// Note that syslog tracing is independent of BoxDebugTraceOn,
// but stdout tracing is not
@@ -96,13 +104,21 @@
#define THROW_EXCEPTION(type, subtype) \
{ \
OPTIONAL_DO_BACKTRACE \
- BOX_WARNING("Exception thrown: " #type "(" #subtype ") at " \
- __FILE__ "(" << __LINE__ << ")") \
+ 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__ << ")") \
+ throw type(type::subtype, message); \
+ }
+
// extra macros for converting to network byte order
-
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif