use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("Failed to connect to {host}:{port}: {source}")]
ConnectionFailed {
host: String,
port: u16,
#[source]
source: std::io::Error,
},
#[error("Connection timed out after {timeout_secs} seconds")]
Timeout { timeout_secs: u32 },
#[error("Read timed out after {timeout_secs} seconds - no data received")]
ReadTimeout { timeout_secs: u32 },
#[error("Authentication failed for {host} (user: {username})")]
AuthenticationFailed { host: String, username: String },
#[error("Mountpoint '{mountpoint}' not found on {host}")]
MountpointNotFound { host: String, mountpoint: String },
#[error("HTTP error from {host}: {status_code} {reason}")]
HttpError {
host: String,
status_code: u16,
reason: String,
},
#[error("TLS error: {message}")]
TlsError { message: String },
#[error("Network error: {source}")]
NetworkError {
#[source]
source: std::io::Error,
},
#[error("Stream disconnected: {reason}")]
StreamDisconnected { reason: String },
#[error("Invalid configuration: {message}")]
InvalidConfig { message: String },
#[error("Failed to parse sourcetable: {message}")]
SourcetableParseError { message: String },
#[error("Proxy error: {message}")]
ProxyError { message: String },
}
impl Error {
pub fn connection_failed(host: &str, port: u16, source: std::io::Error) -> Self {
Self::ConnectionFailed {
host: host.to_string(),
port,
source,
}
}
}