Add `src/cpp-common/bt2/lib-error.hpp`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 11 Dec 2020 00:29:14 +0000 (19:29 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jan 2022 16:22:26 +0000 (11:22 -0500)
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

src/cpp-common/bt2/lib-error.hpp [new file with mode: 0644]

diff --git a/src/cpp-common/bt2/lib-error.hpp b/src/cpp-common/bt2/lib-error.hpp
new file mode 100644 (file)
index 0000000..646b7fc
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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
This page took 0.024921 seconds and 4 git commands to generate.