trezor_client/transport/
error.rs

1//! # Error Handling
2
3/// Trezor error.
4#[derive(Debug, thiserror::Error)]
5pub enum Error {
6    /// [rusb] error.
7    #[error(transparent)]
8    Usb(#[from] rusb::Error),
9
10    /// [std::io] error.
11    #[error(transparent)]
12    IO(#[from] std::io::Error),
13
14    /// The device to connect to was not found.
15    #[error("the device to connect to was not found")]
16    DeviceNotFound,
17
18    /// The device is no longer available.
19    #[error("the device is no longer available")]
20    DeviceDisconnected,
21
22    /// The device produced a data chunk of unexpected size.
23    #[error("the device produced a data chunk of unexpected size")]
24    UnexpectedChunkSizeFromDevice(usize),
25
26    /// Timeout expired while reading from device.
27    #[error("timeout expired while reading from device")]
28    DeviceReadTimeout,
29
30    /// The device sent a chunk with a wrong magic value.
31    #[error("the device sent a chunk with a wrong magic value")]
32    DeviceBadMagic,
33
34    /// The device sent a message with a wrong session id.
35    #[error("the device sent a message with a wrong session id")]
36    DeviceBadSessionId,
37
38    /// The device sent an unexpected sequence number.
39    #[error("the device sent an unexpected sequence number")]
40    DeviceUnexpectedSequenceNumber,
41
42    /// Received a non-existing message type from the device.
43    #[error("received a non-existing message type from the device")]
44    InvalidMessageType(u32),
45
46    /// Unable to determine device serial number.
47    #[error("unable to determine device serial number")]
48    NoDeviceSerial,
49}