[Mobies-commit] [commit] r3809 - UDM/trunk/include

ksmyth at redhat1.isis.vanderbilt.edu ksmyth at redhat1.isis.vanderbilt.edu
Fri Jul 29 13:58:14 CDT 2011


Author: ksmyth
Date: Fri Jul 29 13:58:14 2011
New Revision: 3809

Log:
Make stacktraces on udm_exceptions opt-in: if a project is compiled with stacktraces on exceptions, it cant link against any released Udm version

Modified:
   UDM/trunk/include/ErrHand.h

Modified: UDM/trunk/include/ErrHand.h
==============================================================================
--- UDM/trunk/include/ErrHand.h	Thu Jul 28 14:21:30 2011	(r3808)
+++ UDM/trunk/include/ErrHand.h	Fri Jul 29 13:58:14 2011	(r3809)
@@ -73,13 +73,21 @@
 
 class udm_exception : public std::exception
 {
+	std::string get_stacktrace()
+	{
+#ifdef UDM_EXCEPTION_USES_STACKTRACE
+		return UdmUtil::stacktrace();
+#else
+		return "";
+#endif
+	}
 public:
-	udm_exception() throw() : stacktrace(UdmUtil::stacktrace()) { _init(); }
-	udm_exception(const udm_exception &a) throw() : description(a.description), stacktrace(UdmUtil::stacktrace()) { _init(); }
-	udm_exception(const std::string &d) throw() : description(d), stacktrace(UdmUtil::stacktrace()) { _init(); }
-	udm_exception(const char *d) throw() : description(d), stacktrace(UdmUtil::stacktrace()) { _init(); }
+	udm_exception() throw() : stacktrace(get_stacktrace()) { _init(); }
+	udm_exception(const udm_exception &a) throw() : description(a.description), stacktrace(get_stacktrace()) { _init(); }
+	udm_exception(const std::string &d) throw() : description(d), stacktrace(get_stacktrace()) { _init(); }
+	udm_exception(const char *d) throw() : description(d), stacktrace(get_stacktrace()) { _init(); }
 	const udm_exception &operator =(const udm_exception &a) throw()
-		{ description = a.description; stacktrace = UdmUtil::stacktrace(); _init(); return *this; }
+		{ description = a.description; stacktrace = get_stacktrace(); _init(); return *this; }
 	virtual ~udm_exception() throw() { }
 	virtual const char *what() const throw() { return descr_wstack.c_str(); }
 	virtual const char *where() const throw() { return stacktrace.c_str(); }
@@ -92,8 +100,10 @@
 
 	void _init() {
 		descr_wstack = description;
-		descr_wstack += "\n";
-		descr_wstack += stacktrace;
+		if (stacktrace != "") {
+			descr_wstack += "\n";
+			descr_wstack += stacktrace;
+		}
 	}
 
 };


More information about the Mobies-commit mailing list