summaryrefslogtreecommitdiff
path: root/indra/llcommon/llexception.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-08-17 10:45:06 -0400
committerNat Goodspeed <nat@lindenlab.com>2016-08-17 10:45:06 -0400
commit1ed76c382e8b87bff02b6d37cf8acd7f6b1f8063 (patch)
tree936601e1d4ec4b40aeefce361dc6fe5cb29d014e /indra/llcommon/llexception.cpp
parent9c49a6c91dd9b5bbe811fcd91d8992ed6bac33e7 (diff)
MAINT-5011: Add llexception_test.cpp with tests (and conclusions).
llexception_test.cpp is an unusual test source in that it need not be verified on every build, so its invocation in indra/llcommon/CMakeLists.txt is commented out with that remark. Its purpose is to help a developer decide what base class(es) to use for LLException, how to throw and how to catch. Our current conclusions are written up as comments in llexception_test.cpp. Added CRASH_ON_UNHANDLED_EXCEPTION() and LOG_UNHANDLED_EXCEPTION() macros to llexception.h -- macros to log __FILE__, __LINE__ and __PRETTY_FUNCTION__ of the catch site. These invoke functions in llexception.cpp so we don't need to #include llerror.h for every possible catch site.
Diffstat (limited to 'indra/llcommon/llexception.cpp')
-rw-r--r--indra/llcommon/llexception.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/indra/llcommon/llexception.cpp b/indra/llcommon/llexception.cpp
new file mode 100644
index 0000000000..f48509b2aa
--- /dev/null
+++ b/indra/llcommon/llexception.cpp
@@ -0,0 +1,41 @@
+/**
+ * @file llexception.cpp
+ * @author Nat Goodspeed
+ * @date 2016-08-12
+ * @brief Implementation for llexception.
+ *
+ * $LicenseInfo:firstyear=2016&license=viewerlgpl$
+ * Copyright (c) 2016, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+// Precompiled header
+#include "linden_common.h"
+// associated header
+#include "llexception.h"
+// STL headers
+// std headers
+#include <typeinfo>
+// external library headers
+#include <boost/exception/diagnostic_information.hpp>
+// other Linden headers
+#include "llerror.h"
+
+void crash_on_unhandled_exception_(const char* file, int line, const char* pretty_function)
+{
+ // LL_ERRS() terminates, but also propagates message into crash dump.
+ LL_ERRS() << file << "(" << line << "): Unhandled exception caught in " << pretty_function
+ << ":\n" << boost::current_exception_diagnostic_information() << LL_ENDL;
+}
+
+void log_unhandled_exception_(const char* file, int line, const char* pretty_function,
+ const LLContinueError& e)
+{
+ // Use LL_WARNS() because we seriously do not expect this to happen
+ // routinely, but we DO expect to return from this function. Deriving your
+ // exception from LLContinueError implies that such an exception should
+ // NOT be fatal to the viewer, only to its current task.
+ LL_WARNS() << file << "(" << line << "): Unhandled " << typeid(e).name()
+ << " exception caught in " << pretty_function
+ << ":\n" << boost::current_exception_diagnostic_information() << LL_ENDL;
+}