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