use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("Browser automation error: {0}")]
BrowserError(String),
#[error("Interaction emulation error: {0}")]
InteractionError(String),
#[error("Proxy initialization failed: {0}")]
ProxyBindFailed(#[from] std::io::Error),
#[error("HTTP client error: {0}")]
HttpClientError(#[from] wreq::Error),
#[error("Unsolved challenge: {0}")]
Challenge(String),
#[error("State store error: {0}")]
StateStore(String),
#[error("Configuration error: {0}")]
ConfigError(String),
#[error("Internal join error: {0}")]
JoinError(String),
#[error("TLS error: {0}")]
TlsError(String),
#[error("Internal error: {0}")]
Internal(String),
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_error_display_formatting() {
let err = Error::BrowserError("Failed to launch".to_string());
assert_eq!(
err.to_string(),
"Browser automation error: Failed to launch"
);
let err2 = Error::ConfigError("Missing timeout".to_string());
assert_eq!(err2.to_string(), "Configuration error: Missing timeout");
let err3 = Error::Internal("Crash".to_string());
assert_eq!(err3.to_string(), "Internal error: Crash");
let err4 = Error::TlsError("handshake timeout".to_string());
assert_eq!(err4.to_string(), "TLS error: handshake timeout");
}
}