1use thiserror::Error;
4
5#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum Error {
9 #[error("Failed to connect to {host}:{port}: {source}")]
11 ConnectionFailed {
12 host: String,
13 port: u16,
14 #[source]
15 source: std::io::Error,
16 },
17
18 #[error("Connection timed out after {timeout_secs} seconds")]
20 Timeout { timeout_secs: u32 },
21
22 #[error("Read timed out after {timeout_secs} seconds - no data received")]
24 ReadTimeout { timeout_secs: u32 },
25
26 #[error("Authentication failed for {host} (user: {username})")]
28 AuthenticationFailed { host: String, username: String },
29
30 #[error("Mountpoint '{mountpoint}' not found on {host}")]
32 MountpointNotFound { host: String, mountpoint: String },
33
34 #[error("HTTP error from {host}: {status_code} {reason}")]
36 HttpError {
37 host: String,
38 status_code: u16,
39 reason: String,
40 },
41
42 #[error("TLS error: {message}")]
44 TlsError { message: String },
45
46 #[error("Network error: {source}")]
48 NetworkError {
49 #[source]
50 source: std::io::Error,
51 },
52
53 #[error("Stream disconnected: {reason}")]
55 StreamDisconnected { reason: String },
56
57 #[error("Invalid configuration: {message}")]
59 InvalidConfig { message: String },
60
61 #[error("Failed to parse sourcetable: {message}")]
63 SourcetableParseError { message: String },
64}
65
66impl Error {
67 pub fn connection_failed(host: &str, port: u16, source: std::io::Error) -> Self {
69 Self::ConnectionFailed {
70 host: host.to_string(),
71 port,
72 source,
73 }
74 }
75}