5#ifndef ASTARTE_DEVICE_SDK_ERRORS_H
6#define ASTARTE_DEVICE_SDK_ERRORS_H
17#if defined(ASTARTE_USE_TL_EXPECTED)
18#include <tl/expected.hpp>
34#if defined(ASTARTE_USE_TL_EXPECTED)
35namespace astarte_tl = ::tl;
37namespace astarte_tl = ::std;
56#if !defined(ASTARTE_TRANSPORT_GRPC)
86#if !defined(ASTARTE_TRANSPORT_GRPC)
129 [[nodiscard]]
auto message() const -> const std::
string&;
135 [[nodiscard]] auto
type() const -> const std::
string&;
161 std::
string message_;
182 static constexpr std::string_view k_type_ =
"DataSerializationError";
202 static constexpr std::string_view k_type_ =
"InternalError";
222 static constexpr std::string_view k_type_ =
"FileOpenError";
242 static constexpr std::string_view k_type_ =
"InvalidInputError";
262 static constexpr std::string_view k_type_ =
"OperationRefusedError";
297 static constexpr std::string_view k_type_ =
"GrpcLibError";
317 static constexpr std::string_view k_type_ =
"MsgHubError";
341 static constexpr std::string_view k_type_ =
"InterfaceValidationError";
361 static constexpr std::string_view k_type_ =
"InvalidInterfaceVersionError";
381 static constexpr std::string_view k_type_ =
"InvalidInterfaceTypeError";
401 static constexpr std::string_view k_type_ =
"InvalidInterfaceOwnershipeError";
421 static constexpr std::string_view k_type_ =
"InvalidInterfaceAggregationError";
441 static constexpr std::string_view k_type_ =
"InvalidAstarteTypeError";
461 static constexpr std::string_view k_type_ =
"InvalidReliabilityError";
481 static constexpr std::string_view k_type_ =
"InvalidRetentionError";
501 static constexpr std::string_view k_type_ =
"InvalidDatabaseRetentionPolicyError";
506#if !defined(ASTARTE_TRANSPORT_GRPC)
522 template <
typename ParseContext>
523 constexpr auto parse(ParseContext& ctx)
const {
533 template <
typename FormatContext>
536 [&ctx](
const auto& err) {
538 return astarte_fmt::format_to(ctx.out(),
"{}", base_err);
552 template <
typename ParseContext>
553 constexpr auto parse(ParseContext& ctx)
const {
563 template <
typename FormatContext>
565 auto out = astarte_fmt::format_to(ctx.out(),
"{}: {}", err.
type(), err.
message());
571 out = astarte_fmt::format_to(out,
"\n{}-> {}: {}", indent, nested->type(), nested->message());
572 current = nested.get();
Specific error for when a serialization operation failed.
Definition errors.hpp:166
DataSerializationError(std::string_view message)
Standard error constructor.
DataSerializationError(std::string_view message, const Error &other)
Nested error constructor.
Base error class representing any possible error from the Astarte device library.
Definition errors.hpp:102
auto message() const -> const std::string &
Retrieves the error message.
virtual ~ErrorBase()=default
Destructor for the Astarte error.
auto operator=(ErrorBase &&) -> ErrorBase &=default
Default move assignment operator.
ErrorBase(const ErrorBase &)=default
Default copy constructor.
auto nested_error() const -> const std::shared_ptr< ErrorBase > &
Retrieves the nested error, if any.
auto type() const -> const std::string &
Retrieves the error type string.
auto operator=(const ErrorBase &) -> ErrorBase &=default
Default copy assignment operator.
ErrorBase(ErrorBase &&)=delete
Delete move constructor.
Specific error for when a file cannot be opened.
Definition errors.hpp:206
FileOpenError(std::string_view filename, const Error &other)
Nested error constructor.
FileOpenError(std::string_view filename)
Standard error constructor.
Error reported by the gRPC transport library.
Definition errors.hpp:266
GrpcLibError(std::string_view message, const Error &other)
Nested error constructor.
GrpcLibError(std::uint64_t code, std::string_view message)
Error constructor including gRPC error codes.
GrpcLibError(std::string_view message)
Standard error constructor.
GrpcLibError(std::uint64_t code, std::string_view message, const Error &other)
Nested error constructor including gRPC error codes.
Error during the Interface validation process.
Definition errors.hpp:325
InterfaceValidationError(std::string_view message, const Error &other)
Nested error constructor.
InterfaceValidationError(std::string_view message)
Standard error constructor.
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:186
InternalError(std::string_view message, const Error &other)
Nested error constructor.
InternalError(std::string_view message)
Standard error constructor.
Error indicating that the provided Astarte type is incorrect.
Definition errors.hpp:425
InvalidAstarteTypeError(std::string_view message)
Standard error constructor.
InvalidAstarteTypeError(std::string_view message, const Error &other)
Nested error constructor.
Error indicating that the provided Astarte database retention policy is incorrect.
Definition errors.hpp:485
InvalidDatabaseRetentionPolicyError(std::string_view message)
Standard error constructor.
InvalidDatabaseRetentionPolicyError(std::string_view message, const Error &other)
Nested error constructor.
Error indicating that the provided interface aggregation is incorrect.
Definition errors.hpp:405
InvalidInterfaceAggregationError(std::string_view message, const Error &other)
Nested error constructor.
InvalidInterfaceAggregationError(std::string_view message)
Standard error constructor.
Error indicating that the provided interface ownership is incorrect.
Definition errors.hpp:385
InvalidInterfaceOwnershipeError(std::string_view message)
Standard error constructor.
InvalidInterfaceOwnershipeError(std::string_view message, const Error &other)
Nested error constructor.
Error indicating that the provided interface type is incorrect.
Definition errors.hpp:365
InvalidInterfaceTypeError(std::string_view message, const Error &other)
Nested error constructor.
InvalidInterfaceTypeError(std::string_view message)
Standard error constructor.
Error indicating that the minor or major version of an interface is incorrect.
Definition errors.hpp:345
InvalidInterfaceVersionError(std::string_view message, const Error &other)
Nested error constructor.
InvalidInterfaceVersionError(std::string_view message)
Standard error constructor.
Error indicating that the provided Astarte reliability is incorrect.
Definition errors.hpp:445
InvalidReliabilityError(std::string_view message, const Error &other)
Nested error constructor.
InvalidReliabilityError(std::string_view message)
Standard error constructor.
Error indicating that the provided Astarte retention is incorrect.
Definition errors.hpp:465
InvalidRetentionError(std::string_view message)
Standard error constructor.
InvalidRetentionError(std::string_view message, const Error &other)
Nested error constructor.
Error reported by the Astarte message hub library.
Definition errors.hpp:301
MsgHubError(std::string_view message, const Error &other)
Nested error constructor.
MsgHubError(std::string_view message)
Standard error constructor.
An operation which is not permitted according to the current device status was attempted.
Definition errors.hpp:246
OperationRefusedError(std::string_view message)
Standard error constructor.
OperationRefusedError(std::string_view message, const Error &other)
Nested error constructor.
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:219
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:99
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:259
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:79
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:119
Specific MQTT connection error.
Definition errors.hpp:279
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:30
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:59
Specific error for when the configuration to connect the device to Astarte is invalid.
Definition errors.hpp:199
Specific error for when reading from a file.
Definition errors.hpp:159
Specific error for when an operation failed due to an internal error.
Definition errors.hpp:139
Specific error for when a UUID operation failed.
Definition errors.hpp:239
Specific error for when writing to a file.
Definition errors.hpp:179
specific error definitions for the Astarte device SDK.
Namespace for Astarte device functionality using the MQTT transport protocol.
Definition errors.hpp:57
Umbrella namespace for the Astarte device library.
Definition data.hpp:29
std::variant< DataSerializationError, InternalError, FileOpenError, InvalidInputError, InterfaceValidationError, InvalidInterfaceVersionError, InvalidInterfaceTypeError, InvalidInterfaceOwnershipeError, InvalidInterfaceAggregationError, InvalidAstarteTypeError, InvalidReliabilityError, InvalidRetentionError, InvalidDatabaseRetentionPolicyError, OperationRefusedError, GrpcLibError, MsgHubError, mqtt::JsonParsingError, mqtt::DeviceRegistrationError, mqtt::PairingApiError, mqtt::MqttError, mqtt::InvalidUrlError, mqtt::RetrieveBrokerUrlError, mqtt::ReadCredentialError, mqtt::WriteCredentialError, mqtt::PairingConfigError, mqtt::CryptoError, mqtt::UuidError, mqtt::HttpError, mqtt::MqttConnectionError > Error
Variant type representing any error from the Astarte device library.
Definition errors.hpp:80
Global namespace for all Astarte related functionality.
Definition data.hpp:29