diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-04 22:45:02 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-04 22:45:02 +0000 |
commit | a34c6e774c8cd4365fbbe093e5d0d8c71904a9e1 (patch) | |
tree | 67a6f957a69746bc3679404732262ec28fcfd1f9 /vespalib | |
parent | 9128ca112e452533b87122d51934709913566657 (diff) |
Move it out so it can be tested.
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/alloc.cpp | 13 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/exception.cpp | 11 | ||||
-rw-r--r-- | vespalib/src/vespa/vespalib/util/exception.h | 9 |
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> |