summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-09-04 22:45:02 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2016-09-04 22:45:02 +0000
commita34c6e774c8cd4365fbbe093e5d0d8c71904a9e1 (patch)
tree67a6f957a69746bc3679404732262ec28fcfd1f9 /vespalib
parent9128ca112e452533b87122d51934709913566657 (diff)
Move it out so it can be tested.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/alloc.cpp13
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.cpp11
-rw-r--r--vespalib/src/vespa/vespalib/util/exception.h9
3 files changed, 20 insertions, 13 deletions
diff --git a/vespalib/src/vespa/vespalib/util/alloc.cpp b/vespalib/src/vespa/vespalib/util/alloc.cpp
index b5897a71fda..94f4aeed27c 100644
--- a/vespalib/src/vespa/vespalib/util/alloc.cpp
+++ b/vespalib/src/vespa/vespalib/util/alloc.cpp
@@ -92,19 +92,6 @@ size_t sum(const MMapStore & s)
return sum;
}
-class SilenceUncaughtException {
-public:
- SilenceUncaughtException(const std::exception & e) : _e(e) { }
- ~SilenceUncaughtException() {
- if (std::uncaught_exception()) {
- LOG(fatal, "Will exit with code 66 due to: %s", _e.what());
- exit(66); //OR _exit() ?
- }
- }
-private:
- const std::exception & _e;
-};
-
}
void * MMapAlloc::alloc(size_t sz)
{
diff --git a/vespalib/src/vespa/vespalib/util/exception.cpp b/vespalib/src/vespa/vespalib/util/exception.cpp
index bba391ded0f..ea001660f72 100644
--- a/vespalib/src/vespa/vespalib/util/exception.cpp
+++ b/vespalib/src/vespa/vespalib/util/exception.cpp
@@ -9,6 +9,9 @@
#include <vespa/vespalib/util/backtrace.h>
#endif
+#include <vespa/log/log.h>
+LOG_SETUP(".vespa.exception");
+
namespace vespalib {
ExceptionPtr::ExceptionPtr()
@@ -150,4 +153,12 @@ Exception::toString() const
return str;
}
+SilenceUncaughtException::~SilenceUncaughtException()
+{
+ if (std::uncaught_exception()) {
+ LOG(fatal, "Will exit with code 66 due to: %s", _e.what());
+ exit(66); //OR _exit() ?
+ }
+}
+
} // namespace vespalib
diff --git a/vespalib/src/vespa/vespalib/util/exception.h b/vespalib/src/vespa/vespalib/util/exception.h
index b3c38f72b1d..b47c6c76f74 100644
--- a/vespalib/src/vespa/vespalib/util/exception.h
+++ b/vespalib/src/vespa/vespalib/util/exception.h
@@ -233,6 +233,15 @@ public:
virtual string toString() const;
};
+class SilenceUncaughtException {
+public:
+ SilenceUncaughtException(const std::exception & e) : _e(e) { }
+ ~SilenceUncaughtException();
+private:
+ const std::exception & _e;
+};
+
+
} // namespace vespalib
#include <vespa/vespalib/util/exceptions.h>