sessiond: introduce ltt_session::locked_ref look-up functions
[lttng-tools.git] / src / common / exception.hpp
index f878b9cf541707e5c425e2ea746125662bbfa52b..340231734d3620b113f622ab7879c7b1bac5bae2 100644 (file)
@@ -23,6 +23,8 @@
 #define LTTNG_THROW_POSIX(msg, errno_code) \
        throw lttng::posix_error(msg, errno_code, LTTNG_SOURCE_LOCATION())
 #define LTTNG_THROW_ERROR(msg) throw lttng::runtime_error(msg, LTTNG_SOURCE_LOCATION())
+#define LTTNG_THROW_ALLOCATION_FAILURE_ERROR(msg, allocation_size) \
+       throw lttng::allocation_failure(msg, allocation_size, LTTNG_SOURCE_LOCATION())
 #define LTTNG_THROW_UNSUPPORTED_ERROR(msg) \
        throw lttng::unsupported_error(msg, LTTNG_SOURCE_LOCATION())
 #define LTTNG_THROW_COMMUNICATION_ERROR(msg) \
@@ -92,6 +94,22 @@ public:
        lttng::source_location source_location;
 };
 
+/**
+ * @class allocation_failure
+ * @brief Represents an allocation failure.
+ *
+ * Thrown when an allocation fails. Differs from bad_alloc in that it offers a message and a
+ * source location.
+ */
+class allocation_failure : public lttng::runtime_error {
+public:
+       explicit allocation_failure(const std::string& msg,
+                                   std::size_t allocation_size,
+                                   const lttng::source_location& source_location);
+
+       std::size_t allocation_size;
+};
+
 /**
  * @class unsupported_error
  * @brief Represents an error for unsupported features.
This page took 0.023306 seconds and 4 git commands to generate.