diff options
Diffstat (limited to 'vespalib/src/vespa/vespalib/util/unwind_message.h')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/unwind_message.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vespalib/src/vespa/vespalib/util/unwind_message.h b/vespalib/src/vespa/vespalib/util/unwind_message.h new file mode 100644 index 00000000000..5133e92742d --- /dev/null +++ b/vespalib/src/vespa/vespalib/util/unwind_message.h @@ -0,0 +1,33 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/vespalib/stllike/string.h> + +namespace vespalib { + +/** + * This class contains a message that will be printed to stderr if the + * object is destructed due to stack unwinding caused by an exception. + **/ +class UnwindMessage { +private: + int _num_active; + vespalib::string _message; +public: + UnwindMessage(const vespalib::string &msg); + UnwindMessage(UnwindMessage &&rhs); + UnwindMessage(const UnwindMessage &) = delete; + UnwindMessage &operator=(const UnwindMessage &) = delete; + UnwindMessage &operator=(UnwindMessage &&) = delete; + ~UnwindMessage(); +}; + +extern UnwindMessage unwind_msg(const char *fmt, ...) +#ifdef __GNUC__ + // Add printf format checks with gcc + __attribute__ ((format (printf,1,2))) +#endif + ; + +} // namespace |