stealthscraper_rs/
error.rs1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("Browser automation error: {0}")]
10 BrowserError(String),
11
12 #[error("Interaction emulation error: {0}")]
14 InteractionError(String),
15
16 #[error("Proxy initialization failed: {0}")]
18 ProxyBindFailed(#[from] std::io::Error),
19
20 #[error("HTTP client error: {0}")]
22 HttpClientError(#[from] wreq::Error),
23
24 #[error("Unsolved challenge: {0}")]
26 Challenge(String),
27
28 #[error("State store error: {0}")]
30 StateStore(String),
31
32 #[error("Configuration error: {0}")]
34 ConfigError(String),
35
36 #[error("Internal join error: {0}")]
38 JoinError(String),
39
40 #[error("TLS error: {0}")]
42 TlsError(String),
43
44 #[error("Internal error: {0}")]
46 Internal(String),
47}
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_error_display_formatting() {
55 let err = Error::BrowserError("Failed to launch".to_string());
56 assert_eq!(
57 err.to_string(),
58 "Browser automation error: Failed to launch"
59 );
60
61 let err2 = Error::ConfigError("Missing timeout".to_string());
62 assert_eq!(err2.to_string(), "Configuration error: Missing timeout");
63
64 let err3 = Error::Internal("Crash".to_string());
65 assert_eq!(err3.to_string(), "Internal error: Crash");
66
67 let err4 = Error::TlsError("handshake timeout".to_string());
68 assert_eq!(err4.to_string(), "TLS error: handshake timeout");
69 }
70}