From 1fdc674af0912142072fa45908d464e95f0c4bf6 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Thu, 10 Dec 2020 19:29:14 -0500 Subject: [PATCH] Add `src/cpp-common/bt2/lib-error.hpp` This new file contains classes for equivalent common libbabeltrace2 errors to be thrown by the libbabeltrace2 C++ interface code. Signed-off-by: Philippe Proulx Change-Id: Ie70002c0b15e8b6c139b57e8a9ca5f7be5ef98ed Reviewed-on: https://review.lttng.org/c/babeltrace/+/4535 --- src/cpp-common/bt2/lib-error.hpp | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/cpp-common/bt2/lib-error.hpp diff --git a/src/cpp-common/bt2/lib-error.hpp b/src/cpp-common/bt2/lib-error.hpp new file mode 100644 index 00000000..646b7fca --- /dev/null +++ b/src/cpp-common/bt2/lib-error.hpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2020 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP +#define BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP + +#include +#include + +namespace bt2 { + +/* + * Any library error. + */ +class LibError : public std::runtime_error +{ +public: + explicit LibError(const std::string& msg = "Error") : std::runtime_error {msg} + { + } +}; + +/* + * Memory error. + */ +class LibMemoryError : public LibError +{ +public: + LibMemoryError() : LibError {"Memory error"} + { + } +}; + +/* + * Overflow error. + */ +class LibOverflowError : public LibError +{ +public: + LibOverflowError() : LibError {"Overflow error"} + { + } +}; + +} // namespace bt2 + +#endif // BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP -- 2.34.1