diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2016-08-17 15:40:03 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2016-08-17 15:40:03 -0400 |
commit | 993f54f6e91d78a9c2e1389ad878d6bd46e9be5b (patch) | |
tree | 138fb7e1213ab0100b4662d30c4f60921e920f37 /indra/llcommon | |
parent | db4f13e7bcfc7ef61f750152494f1e52ad5a9080 (diff) |
MAINT-5011: Try to enrich catch (...) logging throughout viewer.
Turns out we have a surprising number of catch (...) clauses in the viewer
code base. If all we currently do is
LL_ERRS() << "unknown exception" << LL_ENDL;
then call CRASH_ON_UNHANDLED_EXCEPTION() instead. If what we do is
LL_WARNS() << "unknown exception" << LL_ENDL;
then call LOG_UNHANDLED_EXCEPTION() instead.
Since many places need LOG_UNHANDLED_EXCEPTION() and nobody catches
LLContinueError yet, eliminate LLContinueError& parameter from
LOG_UNHANDLED_EXCEPTION(). This permits us to use the same log message as
CRASH_ON_UNHANDLED_EXCEPTION(), just with a different severity level.
Where a catch (...) clause actually provides contextual information, or makes
an error string, add boost::current_exception_diagnostic_information() to try
to figure out actual exception class and message.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llexception.cpp | 29 | ||||
-rw-r--r-- | indra/llcommon/llexception.h | 9 |
2 files changed, 23 insertions, 15 deletions
diff --git a/indra/llcommon/llexception.cpp b/indra/llcommon/llexception.cpp index f48509b2aa..9a6dfee3f1 100644 --- a/indra/llcommon/llexception.cpp +++ b/indra/llcommon/llexception.cpp @@ -21,21 +21,28 @@ // other Linden headers #include "llerror.h" +namespace { +// used by crash_on_unhandled_exception_() and log_unhandled_exception_() +void log_unhandled_exception_(LLError::ELevel level, + const char* file, int line, const char* pretty_function) +{ + // log same message but allow caller-specified severity level + // lllog() is the macro underlying LL_ERRS(), LL_WARNS() et al. + lllog(level, false) << file << "(" << line << "): Unhandled exception caught in " + << pretty_function + << ":\n" << boost::current_exception_diagnostic_information() << LL_ENDL; +} +} + 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; + // LL_ERRS() terminates and propagates message into crash dump. + log_unhandled_exception_(LLError::LEVEL_ERROR, file, line, pretty_function); } -void log_unhandled_exception_(const char* file, int line, const char* pretty_function, - const LLContinueError& e) +void log_unhandled_exception_(const char* file, int line, const char* pretty_function) { // 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; + // routinely, but we DO expect to return from this function. + log_unhandled_exception_(LLError::LEVEL_WARN, file, line, pretty_function); } diff --git a/indra/llcommon/llexception.h b/indra/llcommon/llexception.h index e9e25ae689..2a0f5e79eb 100644 --- a/indra/llcommon/llexception.h +++ b/indra/llcommon/llexception.h @@ -74,9 +74,10 @@ struct LLContinueError: public LLException crash_on_unhandled_exception_(__FILE__, __LINE__, __PRETTY_FUNCTION__) void crash_on_unhandled_exception_(const char*, int, const char*); -/// Call this from a catch (const LLContinueError&) clause -#define LOG_UNHANDLED_EXCEPTION(EXC) \ - log_unhandled_exception_(__FILE__, __LINE__, __PRETTY_FUNCTION__, EXC) -void log_unhandled_exception_(const char*, int, const char*, const LLContinueError&); +/// Call this from a catch (const LLContinueError&) clause, or from a catch +/// (...) clause in which you do NOT want the viewer to crash. +#define LOG_UNHANDLED_EXCEPTION() \ + log_unhandled_exception_(__FILE__, __LINE__, __PRETTY_FUNCTION__) +void log_unhandled_exception_(const char*, int, const char*); #endif /* ! defined(LL_LLEXCEPTION_H) */ |