summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests/wrapllerrs.h
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2019-11-13 10:50:25 +0200
committerAndreyL ProductEngine <alihatskiy@productengine.com>2019-11-13 10:50:25 +0200
commitf83ada32f728740254668792f9d77b5745d80d2e (patch)
tree593a31ab109e1e8b088d0c2a5536e73cb6b9a050 /indra/llcommon/tests/wrapllerrs.h
parentb1ac8092eecf5fc9dc4b4867370a51e5dfba4331 (diff)
parent78bdf57ad6610b34389226bf941ba736ca0c2225 (diff)
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/llcommon/tests/wrapllerrs.h')
-rw-r--r--indra/llcommon/tests/wrapllerrs.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/llcommon/tests/wrapllerrs.h b/indra/llcommon/tests/wrapllerrs.h
index 08fbf19b1c..b07d5afbd8 100644
--- a/indra/llcommon/tests/wrapllerrs.h
+++ b/indra/llcommon/tests/wrapllerrs.h
@@ -37,6 +37,7 @@
#include "llerrorcontrol.h"
#include "llexception.h"
#include "stringize.h"
+#include "../test/catch_and_store_what_in.h"
#include <boost/bind.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
@@ -81,6 +82,31 @@ struct WrapLLErrs
LLTHROW(FatalException(message));
}
+ /// Convenience wrapper for catch_what<FatalException>()
+ //
+ // The implementation makes it clear that this function need not be a
+ // member; it could easily be a free function. It is a member because it
+ // makes no sense to attempt to catch FatalException unless there is a
+ // WrapLLErrs instance in scope. Without a live WrapLLErrs instance, any
+ // LL_ERRS() reached by code within 'func' would terminate the test
+ // program instead of throwing FatalException.
+ //
+ // We were tempted to introduce a free function, likewise accepting
+ // arbitrary 'func', that would instantiate WrapLLErrs and then call
+ // catch_llerrs() on that instance. We decided against it, for this
+ // reason: on extending a test function containing a single call to that
+ // free function, a maintainer would most likely make additional calls to
+ // that free function, instead of switching to an explicit WrapLLErrs
+ // declaration with several calls to its catch_llerrs() member function.
+ // Even a construct such as WrapLLErrs().catch_llerrs(...) would make the
+ // object declaration more visible; it's not unreasonable to expect a
+ // maintainer to extend that by naming and reusing the WrapLLErrs instance.
+ template <typename FUNC>
+ std::string catch_llerrs(FUNC func)
+ {
+ return catch_what<FatalException>(func);
+ }
+
std::string error;
LLError::SettingsStoragePtr mPriorErrorSettings;
LLError::FatalFunction mPriorFatal;