async_mqtt 9.0.1
Loading...
Searching...
No Matches
error.hpp
1// Copyright Takatoshi Kondo 2024
2//
3// Distributed under the Boost Software License, Version 1.0.
4// (See accompanying file LICENSE_1_0.txt or copy at
5// http://www.boost.org/LICENSE_1_0.txt)
6
7#if !defined(ASYNC_MQTT_ERROR_HPP)
8#define ASYNC_MQTT_ERROR_HPP
9
10#include <exception>
11#include <sstream>
12#include <string_view>
13
14#include <boost/system/error_code.hpp>
15#include <boost/system/system_error.hpp>
16#include <boost/assert.hpp>
17#include <boost/operators.hpp>
18
23namespace async_mqtt {
24
34namespace sys = boost::system;
35
45namespace errc = sys::errc;
46
56using error_code = sys::error_code;
57
67using system_error = sys::system_error;
68
69
71
99
114enum class mqtt_error {
115 partial_error_detected = 0x0101,
116 all_error_detected = 0x0180,
121 packet_not_regulated = 0x0186,
122};
123
136
148constexpr char const* mqtt_error_to_string(mqtt_error v);
149
162std::ostream& operator<<(std::ostream& o, mqtt_error v);
163
174sys::error_category const& get_mqtt_error_category();
175
177
194enum class connect_return_code : std::uint8_t {
195 accepted = 0,
200 not_authorized = 5,
201};
202
215
228
241std::ostream& operator<<(std::ostream& o, connect_return_code v);
242
253sys::error_category const& get_connect_return_code_category();
254
256
274enum class suback_return_code : std::uint8_t {
275 success_maximum_qos_0 = 0x00,
276 success_maximum_qos_1 = 0x01,
277 success_maximum_qos_2 = 0x02,
278 failure = 0x80,
279};
280
293
306
319std::ostream& operator<<(std::ostream& o, suback_return_code v);
320
331sys::error_category const& get_suback_return_code_category();
332
334
356enum class connect_reason_code : std::uint8_t {
357 success = 0x00,
358 unspecified_error = 0x80,
359 malformed_packet = 0x81,
360 protocol_error = 0x82,
365 not_authorized = 0x87,
366 server_unavailable = 0x88,
367 server_busy = 0x89,
368 banned = 0x8a,
370 topic_name_invalid = 0x90,
371 packet_too_large = 0x95,
372 quota_exceeded = 0x97,
374 retain_not_supported = 0x9a,
375 qos_not_supported = 0x9b,
376 use_another_server = 0x9c,
377 server_moved = 0x9d,
379};
380
393
406
419std::ostream& operator<<(std::ostream& o, connect_reason_code v);
420
431sys::error_category const& get_connect_reason_code_category();
432
434
482
495
508
521std::ostream& operator<<(std::ostream& o, disconnect_reason_code v);
522
533sys::error_category const& get_disconnect_reason_code_category();
534
536
567
580
593
606std::ostream& operator<<(std::ostream& o, suback_reason_code v);
607
618sys::error_category const& get_suback_reason_code_category();
619
621
638enum class unsuback_reason_code : std::uint8_t {
639 success = 0x00,
641 unspecified_error = 0x80,
643 not_authorized = 0x87,
644 topic_filter_invalid = 0x8f,
646};
647
660
673
686std::ostream& operator<<(std::ostream& o, unsuback_reason_code v);
687
698sys::error_category const& get_unsuback_reason_code_category();
699
701
718enum class puback_reason_code : std::uint8_t {
719 success = 0x00,
721 unspecified_error = 0x80,
723 not_authorized = 0x87,
724 topic_name_invalid = 0x90,
726 quota_exceeded = 0x97,
728};
729
742
755
768std::ostream& operator<<(std::ostream& o, puback_reason_code v);
769
780sys::error_category const& get_puback_reason_code_category();
781
783
800enum class pubrec_reason_code : std::uint8_t {
801 success = 0x00,
803 unspecified_error = 0x80,
805 not_authorized = 0x87,
806 topic_name_invalid = 0x90,
808 quota_exceeded = 0x97,
810};
811
824
837
850std::ostream& operator<<(std::ostream& o, pubrec_reason_code v);
851
862sys::error_category const& get_pubrec_reason_code_category();
863
865
881enum class pubrel_reason_code : std::uint8_t {
882 success = 0x00,
884};
885
898
911
924std::ostream& operator<<(std::ostream& o, pubrel_reason_code v);
925
936sys::error_category const& get_pubrel_reason_code_category();
937
939
956enum class pubcomp_reason_code : std::uint8_t {
957 success = 0x00,
959};
960
973
986
999std::ostream& operator<<(std::ostream& o, pubcomp_reason_code v);
1000
1011sys::error_category const& get_pubcomp_reason_code_category();
1012
1014
1030enum class auth_reason_code : std::uint8_t {
1031 success = 0x00,
1033 re_authenticate = 0x19,
1034};
1035
1048
1061
1074std::ostream& operator<<(std::ostream& o, auth_reason_code v);
1075
1086sys::error_category const& get_auth_reason_code_category();
1087
1088} // namespace async_mqtt
1089
1091
1092namespace boost::system {
1093
1094template <>
1095struct is_error_code_enum<async_mqtt::mqtt_error> : public std::true_type {};
1096template <>
1097struct is_error_code_enum<async_mqtt::connect_reason_code> : public std::true_type {};
1098template <>
1099struct is_error_code_enum<async_mqtt::connect_return_code> : public std::true_type {};
1100template <>
1101struct is_error_code_enum<async_mqtt::suback_return_code> : public std::true_type {};
1102template <>
1103struct is_error_code_enum<async_mqtt::disconnect_reason_code> : public std::true_type {};
1104template <>
1105struct is_error_code_enum<async_mqtt::suback_reason_code> : public std::true_type {};
1106template <>
1107struct is_error_code_enum<async_mqtt::unsuback_reason_code> : public std::true_type {};
1108template <>
1109struct is_error_code_enum<async_mqtt::puback_reason_code> : public std::true_type {};
1110template <>
1111struct is_error_code_enum<async_mqtt::pubrec_reason_code> : public std::true_type {};
1112template <>
1113struct is_error_code_enum<async_mqtt::pubrel_reason_code> : public std::true_type {};
1114template <>
1115struct is_error_code_enum<async_mqtt::pubcomp_reason_code> : public std::true_type {};
1116template <>
1117struct is_error_code_enum<async_mqtt::auth_reason_code> : public std::true_type {};
1118
1119} // namespace boost::system
1120
1121#include <async_mqtt/impl/error.hpp>
1122
1123#endif // ASYNC_MQTT_ERROR_HPP
sys::error_category const & get_auth_reason_code_category()
get gategory of auth_reason_code
constexpr char const * auth_reason_code_to_string(auth_reason_code v)
stringize auth_reason_code
auth_reason_code
auth reason code It is reported via AUTH packet
Definition error.hpp:1030
@ continue_authentication
Continue authentication (not an error)
@ re_authenticate
Re-authenticate (not an error)
sys::error_category const & get_connect_reason_code_category()
get gategory of connect_reason_code
connect_reason_code
connect reason code It is reported as CONNECT response via CONNACK packet
Definition error.hpp:356
constexpr char const * connect_reason_code_to_string(connect_reason_code v)
stringize connect_reason_code
@ connection_rate_exceeded
Connection rate exceeded.
@ success
Success (not an error)
@ malformed_packet
Malformed Packet.
@ unsupported_protocol_version
Unsupported Protocol Version.
@ client_identifier_not_valid
Client Identifier not valid.
@ retain_not_supported
Retain not supported.
@ bad_authentication_method
Bad authentication method.
@ use_another_server
Use another server.
@ implementation_specific_error
Implementation specific error.
@ qos_not_supported
QoS not supported.
@ packet_too_large
Packet too large.
@ topic_name_invalid
Topic Name invalid.
@ unspecified_error
Unspecified error.
@ payload_format_invalid
Payload format invalid.
connect_return_code
connect return code See https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1....
Definition error.hpp:194
constexpr char const * connect_return_code_to_string(connect_return_code v)
stringize connect_return_code
sys::error_category const & get_connect_return_code_category()
get gategory of connect_return_code
@ accepted
Connection accepted (not an error)
@ identifier_rejected
The Client identifier is correct UTF-8 but not allowed by the Server.
@ not_authorized
The Client is not authorized to connect.
@ unacceptable_protocol_version
The Server does not support the level of the MQTT protocol requested by the Client.
@ bad_user_name_or_password
The data in the user name or password is malformed.
@ server_unavailable
The Network Connection has been made but the MQTT service is unavailable.
disconnect_reason_code
disconnect reason code It is reported via DISCONNECT
Definition error.hpp:451
constexpr char const * disconnect_reason_code_to_string(disconnect_reason_code v)
stringize disconnect_reason_code
sys::error_category const & get_disconnect_reason_code_category()
get gategory of disconnect_reason_code
@ message_rate_too_high
Message rate too high.
@ subscription_identifiers_not_supported
Subscription Identifiers not supported.
@ administrative_action
Administrative action.
@ maximum_connect_time
Maximum connect time.
@ normal_disconnection
Normal disconnection (not an error)
@ wildcard_subscriptions_not_supported
Wildcard Subscriptions not supported.
@ topic_filter_invalid
Topic Filter invalid.
@ session_taken_over
Session taken over.
@ shared_subscriptions_not_supported
Shared Subscriptions not supported.
@ server_shutting_down
Server shutting down.
@ receive_maximum_exceeded
Receive Maximum exceeded.
@ disconnect_with_will_message
Disconnect with Will Message (not an error)
@ topic_alias_invalid
Topic Alias invalid.
@ keep_alive_timeout
Keep Alive timeout.
sys::error_code error_code
sys is a namespace alias of boost::sytem.
Definition error.hpp:56
sys::system_error system_error
system_error is a type alias of boost::sytem::system_error.
Definition error.hpp:67
sys::error_category const & get_mqtt_error_category()
get gategory of mqtt_error
error_code make_error_code(mqtt_error v)
make error code
mqtt_error
general error code
Definition error.hpp:114
constexpr char const * mqtt_error_to_string(mqtt_error v)
stringize mqtt_error
std::ostream & operator<<(std::ostream &o, mqtt_error v)
output to the stream
@ packet_not_allowed_to_store
Packet is not allowd to be stored.
@ partial_error_detected
Some entries have error on suback/unsuback (not an error)
@ all_error_detected
All entries have error on suback/unsuback.
@ packet_identifier_conflict
Packet Identifier conflict.
@ packet_not_regulated
Packet is not regulated.
@ packet_identifier_fully_used
Packet Identifier fully used.
@ packet_not_allowed_to_send
Packet is not allowd to be sent.
puback_reason_code
puback reason code It is reported as PUBLISH (QoS1) response via PUBACK packet
Definition error.hpp:718
sys::error_category const & get_puback_reason_code_category()
get gategory of puback_reason_code
constexpr char const * puback_reason_code_to_string(puback_reason_code v)
stringize puback_reason_code
@ no_matching_subscribers
No matching subscribers (not an error)
constexpr char const * pubcomp_reason_code_to_string(pubcomp_reason_code v)
stringize pubcomp_reason_code
pubcomp_reason_code
pubcomp reason code It is reported as PUBREL response via PUBCOMP packet
Definition error.hpp:956
sys::error_category const & get_pubcomp_reason_code_category()
get gategory of pubcomp_reason_code
constexpr char const * pubrec_reason_code_to_string(pubrec_reason_code v)
stringize pubrec_reason_code
sys::error_category const & get_pubrec_reason_code_category()
get gategory of pubrec_reason_code
pubrec_reason_code
pubrec reason code It is reported as PUBLISH (QoS2) response via PUBREC packet
Definition error.hpp:800
constexpr char const * pubrel_reason_code_to_string(pubrel_reason_code v)
stringize pubrel_reason_code
sys::error_category const & get_pubrel_reason_code_category()
get gategory of pubrel_reason_code
pubrel_reason_code
pubrel reason code It is reported as PUBREC response via PUBREL packet
Definition error.hpp:881
@ packet_identifier_not_found
Packet Identifier not found.
sys::error_category const & get_suback_reason_code_category()
get gategory of suback_reason_code
suback_reason_code
suback reason code It is reported as SUBSCRIBE response via SUBNACK packet
Definition error.hpp:553
constexpr char const * suback_reason_code_to_string(suback_reason_code v)
stringize suback_reason_code
@ granted_qos_2
Granted QoS 2 (not an error)
@ granted_qos_0
Granted QoS 0 (not an error)
@ packet_identifier_in_use
Packet Identifier in use.
@ granted_qos_1
Granted QoS 1 (not an error)
constexpr char const * suback_return_code_to_string(suback_return_code v)
stringize suback_return_code
suback_return_code
MQTT suback_return_code.
Definition error.hpp:274
sys::error_category const & get_suback_return_code_category()
get gategory of suback_return_code
@ success_maximum_qos_1
Success with QoS1 (not an error)
@ success_maximum_qos_2
Success with QoS2 (not an error)
@ success_maximum_qos_0
Success with QoS0 (not an error)
unsuback_reason_code
unsuback reason code It is reported as UNSUBSCRIBE response via UNSUBNACK packet
Definition error.hpp:638
sys::error_category const & get_unsuback_reason_code_category()
get gategory of unsuback_reason_code
constexpr char const * unsuback_reason_code_to_string(unsuback_reason_code v)
stringize unsuback_reason_code
@ no_subscription_existed
No subscription existed (not an error)