#include "cpp-common/optional.hpp"
#include "cpp-common/string_view.hpp"
#include "cpp-common/uuid-view.hpp"
-#include "lib-error.hpp"
+#include "exc.hpp"
#include "value.hpp"
namespace bt2 {
const auto status = bt_clock_class_set_name(this->libObjPtr(), name);
if (status == BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_clock_class_set_description(this->libObjPtr(), description);
if (status == BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
bt_clock_class_cycles_to_ns_from_origin(this->libObjPtr(), value, &nsFromOrigin);
if (status == BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
- throw LibOverflowError {};
+ throw OverflowError {};
}
return nsFromOrigin;
#include <babeltrace2/babeltrace.h>
#include "internal/borrowed-obj.hpp"
-#include "lib-error.hpp"
+#include "exc.hpp"
namespace bt2 {
const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin);
if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) {
- throw LibOverflowError {};
+ throw OverflowError {};
}
return nsFromOrigin;
--- /dev/null
+/*
+ * Copyright (c) 2020-2022 Philippe Proulx <pproulx@efficios.com>
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef BABELTRACE_CPP_COMMON_BT2_EXC_HPP
+#define BABELTRACE_CPP_COMMON_BT2_EXC_HPP
+
+#include <string>
+#include <stdexcept>
+
+#include "cpp-common/exc.hpp"
+
+namespace bt2 {
+
+using Error = bt2_common::Error;
+using OverflowError = bt2_common::OverflowError;
+using MemoryError = bt2_common::MemoryError;
+
+} /* namespace bt2 */
+
+#endif /* BABELTRACE_CPP_COMMON_BT2_EXC_HPP */
#include "cpp-common/optional.hpp"
#include "cpp-common/string_view.hpp"
#include "common-iter.hpp"
-#include "lib-error.hpp"
+#include "exc.hpp"
#include "integer-range-set.hpp"
#include "field-path.hpp"
#include "value.hpp"
this->libObjPtr(), label, ranges.libObjPtr());
if (status == BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
bt_field_class_structure_append_member(this->libObjPtr(), name, fc.libObjPtr());
if (status == BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
if (status ==
BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
if (status ==
BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
&labelArray, &count);
if (status == BT_FIELD_ENUMERATION_GET_MAPPING_LABELS_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
return EnumerationFieldClassMappingLabels {labelArray, count};
bt_field_enumeration_signed_get_mapping_labels(this->libObjPtr(), &labelArray, &count);
if (status == BT_FIELD_ENUMERATION_GET_MAPPING_LABELS_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
return EnumerationFieldClassMappingLabels {labelArray, count};
const auto status = bt_field_string_set_value(this->libObjPtr(), val);
if (status == BT_FIELD_STRING_SET_VALUE_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
return *this;
const auto status = bt_field_array_dynamic_set_length(this->libObjPtr(), length);
if (status == BT_FIELD_DYNAMIC_ARRAY_SET_LENGTH_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
};
#include "internal/borrowed-obj.hpp"
#include "internal/utils.hpp"
#include "integer-range.hpp"
-#include "lib-error.hpp"
+#include "exc.hpp"
namespace bt2 {
const auto status = _Spec::addRange(this->libObjPtr(), lower, upper);
if (status == BT_INTEGER_RANGE_SET_ADD_RANGE_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
#include <type_traits>
-#include "../lib-error.hpp"
+#include "../exc.hpp"
namespace bt2 {
namespace internal {
void validateCreatedObjPtr(const LibObjPtrT libOjbPtr)
{
if (!libOjbPtr) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
+++ /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 */
#include "internal/utils.hpp"
#include "cpp-common/optional.hpp"
#include "cpp-common/string_view.hpp"
-#include "lib-error.hpp"
+#include "exc.hpp"
namespace bt2 {
namespace internal {
const auto status = bt_stream_set_name(this->libObjPtr(), name);
if (status == BT_STREAM_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_trace_set_name(this->libObjPtr(), name);
if (status == BT_TRACE_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_trace_set_environment_entry_integer(this->libObjPtr(), name, val);
if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_trace_set_environment_entry_string(this->libObjPtr(), name, val);
if (status == BT_TRACE_SET_ENVIRONMENT_ENTRY_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_event_class_set_name(this->libObjPtr(), name);
if (status == BT_EVENT_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_event_class_set_emf_uri(this->libObjPtr(), emfUri);
if (status == BT_EVENT_CLASS_SET_EMF_URI_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
bt_event_class_set_payload_field_class(this->libObjPtr(), fc.libObjPtr());
if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
bt_event_class_set_specific_context_field_class(this->libObjPtr(), fc.libObjPtr());
if (status == BT_EVENT_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
const auto status = bt_stream_class_set_name(this->libObjPtr(), name);
if (status == BT_STREAM_CLASS_SET_NAME_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
bt_stream_class_set_packet_context_field_class(this->libObjPtr(), fc.libObjPtr());
if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
bt_stream_class_set_event_common_context_field_class(this->libObjPtr(), fc.libObjPtr());
if (status == BT_STREAM_CLASS_SET_FIELD_CLASS_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
#include "internal/utils.hpp"
#include "cpp-common/optional.hpp"
#include "cpp-common/string_view.hpp"
-#include "lib-error.hpp"
+#include "exc.hpp"
namespace bt2 {
namespace internal {
const auto status = bt_value_string_set(this->libObjPtr(), rawVal);
if (status == BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
return *this;
void _handleAppendLibStatus(const bt_value_array_append_element_status status) const
{
if (status == BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
};
return;
case BT_VALUE_MAP_FOREACH_ENTRY_STATUS_USER_ERROR:
case BT_VALUE_MAP_FOREACH_ENTRY_STATUS_ERROR:
- throw LibError {};
+ throw Error {};
default:
bt_common_abort();
}
return;
case BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_USER_ERROR:
case BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_ERROR:
- throw LibError {};
+ throw Error {};
default:
bt_common_abort();
}
void _handleInsertLibStatus(const bt_value_map_insert_entry_status status) const
{
if (status == BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR) {
- throw LibMemoryError {};
+ throw MemoryError {};
}
}
};