83 std::variant<T, Error>
data;
105 return std::holds_alternative<T>(
data);
121 return std::get<Error>(
data);
142#define RETURN_IF_ERROR(condition, errorCode) \
143do { if (condition) return errorCode; } while (0)
149#define RET_IF_ERR_MSG(condition, errorCode, message) \
152 return CCSDS::Error{errorCode,message}; \
160#define ASSIGN_MV(var, result) \
162 auto&& _res = (result); \
163 if (!_res) return _res.error(); \
164 var = std::move(_res.value()); \
171#define ASSIGN_CP(var, result) \
173auto&& _res = (result); \
174if (!_res) return _res.error(); \
183#define ASSIGN_OR_PRINT(var, result) \
185 auto&& _res = (result); \
187 printf("[ Error ]: Code [%u]: %s\n", static_cast<unsigned>(_res.error().code()), _res.error().message().c_str());; \
189 var = std::move(_res.value()); \
197#define ASSERT_SUCCESS(result) \
199 auto&& _res = (result); \
200 if (!_res.has_value()) return; \
207#define FORWARD_RESULT(result) \
209 auto&& _res = (result); \
210 if (!_res.has_value()) return _res; \
Represents an error with both an error code and a message.
ErrorCode code() const
Retrieves the error code.
ErrorCode m_code
The error type.
Error(const ErrorCode code, std::string message)
Constructs an error with a given error code and message.
const std::string & message() const
Retrieves the error message.
std::string m_message
A detailed message describing the error.
Encapsulates a result that can hold either a value or an Error.
bool has_value() const
Checks if the result contains a valid value.
Result(Error error)
Constructor for failure case.
Result(T value)
Constructor for success case.
Error error() const
Retrieves the stored error.
T & value()
Retrieves the stored value.
std::variant< T, Error > data
Holds either a valid value or an Error.
Contains definitions and classes for handling CCSDS headers.
ErrorCode
Defines various error codes used in CCSDS packet handling.
@ NO_DATA
No data available.
@ FILE_READ_ERROR
Reading from file failure.
@ UNKNOWN_ERROR
Unknown error.
@ INVALID_CHECKSUM
Checksum validation failed.
@ INVALID_APPLICATION_DATA
Application data is invalid.
@ INVALID_DATA
Data is invalid.
@ INVALID_HEADER_DATA
Header data is invalid.
@ CONFIG_FILE_ERROR
Configuration file error.
@ TEMPLATE_SET_FAILURE
Failed to set Template Packet.
@ VALIDATION_FAILURE
Validation Failure.
@ FILE_WRITE_ERROR
Writing to file failure.
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
@ NULL_POINTER
Null pointer encountered.