RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
blenderError.hpp
Go to the documentation of this file.
1
11#ifndef RTCKT_TELSUB_BLENDERERROR_HPP
12#define RTCKT_TELSUB_BLENDERERROR_HPP
13
14#include <cstdint>
15#include <system_error>
16
17namespace rtctk::telSub {
18
35
57class BlenderErrorCategory : public std::error_category {
58public:
64 const char* name() const noexcept override {
65 return "blender";
66 }
67
74 std::string message(int ev) const override {
75 switch (static_cast<GenericBlenderError>(ev)) {
77 return "Success: operation completed successfully";
79 return "Missing required topic in input data";
81 return "Data size does not match expected size";
83 return "Data format is invalid or corrupted";
85 return "Unknown error occurred";
86 default:
87 return "Unknown blender error value";
88 }
89 }
90
97 std::error_code MakeBlenderError(GenericBlenderError e) const noexcept {
98 return {static_cast<int>(e), *this};
99 }
100};
101
118const std::error_category& GetBlenderErrorCategory() noexcept;
119
140std::error_code MakeBlenderError(GenericBlenderError e) noexcept;
141
142} // namespace rtctk::telSub
143
144// Allow implicit conversion from BlenderError to std::error_code
145namespace std {
146template <>
147struct is_error_code_enum<rtctk::telSub::GenericBlenderError> : true_type {};
148} // namespace std
149
150#endif // RTCKT_TELSUB_BLENDERERROR_HPP
Error category for blender errors.
Definition blenderError.hpp:57
std::error_code MakeBlenderError(GenericBlenderError e) const noexcept
Creates an error_code from a BlenderError.
Definition blenderError.hpp:97
std::string message(int ev) const override
Returns a descriptive message for an error code.
Definition blenderError.hpp:74
const char * name() const noexcept override
Returns the name of this error category.
Definition blenderError.hpp:64
GenericBlenderError
Error codes for blender-related errors.
Definition blenderError.hpp:28
@ MissingTopic
Required topic was not found in the input data.
Definition blenderError.hpp:30
@ Success
No error, operation successful.
Definition blenderError.hpp:29
@ SizeMismatch
Data size does not match expected size.
Definition blenderError.hpp:31
@ UnknownError
Generic unknown error.
Definition blenderError.hpp:33
@ InvalidFormat
Data format is invalid or corrupted.
Definition blenderError.hpp:32
Definition main.cpp:23
std::error_code MakeBlenderError(GenericBlenderError e) noexcept
Creates an error_code for a blender error.
Definition blenderError.cpp:29
const std::error_category & GetBlenderErrorCategory() noexcept
Returns a reference to the global blender error category instance.
Definition blenderError.cpp:19
Definition commandReplier.cpp:21
Definition ddsSub.hpp:155