Skip to main content

cloudmqtt/
error.rs

1//
2//   This Source Code Form is subject to the terms of the Mozilla Public
3//   License, v. 2.0. If a copy of the MPL was not distributed with this
4//   file, You can obtain one at http://mozilla.org/MPL/2.0/.
5//
6
7use mqtt_format::v3::connect_return::MConnectReturnCode;
8
9use crate::PacketIOError;
10
11#[derive(Debug, thiserror::Error)]
12pub enum MqttError {
13    #[error("An error occured during the handling of a packet")]
14    Packet(#[from] PacketIOError),
15    #[error("An IO Error occurred")]
16    Io(#[from] std::io::Error),
17    #[error("An error during writing to Buffer occurred")]
18    Buffer(#[from] mqtt_format::v3::errors::MPacketWriteError),
19    #[error("An invalid packet was received")]
20    InvalidPacket,
21    #[error("The connection was already closed")]
22    ConnectionClosed,
23    #[error("The client is already listening for packets")]
24    AlreadyListening,
25    #[error("The server responded with an invalid CONNACK packet")]
26    InvalidConnectionResponse,
27    #[error("The server rejected the connection with the given code")]
28    ConnectionRejected(MConnectReturnCode),
29    #[error("Duplex source closed unexpectedly")]
30    DuplexSourceClosed,
31}