cat_dev/fsemul/pcfs/
errors.rs1use miette::Diagnostic;
4use thiserror::Error;
5
6#[derive(Diagnostic, Error, Debug, PartialEq, Eq)]
8pub enum PCFSApiError {
9 #[error("This packet body is too large to ever fit in a PCFS Sata Packet, is: 0x{0:02X?} bytes long, max is 0xFFFFFFFF!")]
12 #[diagnostic(code(cat_dev::api::fsemul::pcfs::packet_too_large_for_sata))]
13 PacketTooLargeForSata(usize),
14 #[error("The requested path: [{0}] was not inside of a mapped directory, cannot serve.")]
16 #[diagnostic(code(cat_dev::api::fsemul::pcfs::path_not_mapped))]
17 PathNotMapped(String),
18}
19
20#[derive(Diagnostic, Error, Debug, PartialEq, Eq)]
22pub enum SataProtocolError {
23 #[error("Mode string is expected to match '(r|w|a)b?+?', but did not! invalid mode: {0}")]
24 #[diagnostic(code(cat_dev::net::parse::pcfs::sata::bad_mode_string))]
25 BadModeString(String),
26 #[error(
28 "Packet header for PCFS should end with 8 bytes of padding (all 0x0), but was: [{0:02X?}]!"
29 )]
30 #[diagnostic(code(cat_dev::net::parse::pcfs::sata::header_bad_padding))]
31 HeaderBadPadding([u8; 8]),
32 #[error(
36 "Packet header has fields that only the host should ever populate, but they were populated by the non-host: (timestamp: {0:02X}) / (pid: {1:02X}). This is a malformed packet from this device."
37 )]
38 #[diagnostic(code(cat_dev::net::parse::pcfs::sata::header_non_host_set_host_fields))]
39 NonHostSetHostOnlyHeaderFields(u32, u32),
40 #[error("Unknown type of packet for PCFS Sata: {0:02X}!")]
42 #[diagnostic(code(cat_dev::net::parse::pcfs::sata::unknown_type))]
43 UnknownPacketType(u32),
44 #[error("Unknown query type for GetInfo operation: {0}")]
46 #[diagnostic(code(cat_dev::net::parse::pcfs::sata::unknown_get_info_query_type))]
47 UnknownGetInfoQueryType(u32),
48 #[error("Unknown file location to move too: {0}")]
49 #[diagnostic(code(cat_dev::net::parse::pcfs::sata::unknown_file_location))]
50 UnknownFileLocation(u32),
51}