From: Philippe Proulx Date: Fri, 11 Dec 2020 00:29:14 +0000 (-0500) Subject: Add `src/cpp-common/bt2/lib-error.hpp` X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=1fdc674af0912142072fa45908d464e95f0c4bf6 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 --- 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