This new file contains classes for equivalent common libbabeltrace2
errors to be thrown by the libbabeltrace2 C++ interface code.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie70002c0b15e8b6c139b57e8a9ca5f7be5ef98ed
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4535
--- /dev/null
+/*
+ * Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP
+#define BABELTRACE_CPP_COMMON_BT2_LIB_ERROR_HPP
+
+#include <string>
+#include <stdexcept>
+
+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