zendriver_interception/
error.rs1#[derive(Debug, thiserror::Error)]
11#[non_exhaustive]
12pub enum InterceptionError {
13 #[error("call failed: {0}")]
14 Call(Box<zendriver_transport::CallError>),
15
16 #[error("invalid url pattern: {0}")]
17 InvalidPattern(String),
18
19 #[error("interception already started")]
20 AlreadyStarted,
21
22 #[error("interception not started")]
23 NotStarted,
24
25 #[error("subscription channel closed")]
26 SubscriptionClosed,
27
28 #[error("invalid response from CDP: {0}")]
29 InvalidResponse(String),
30
31 #[error("wrong interception stage: this action is only valid at the Response stage")]
32 WrongStage,
33}
34
35impl From<zendriver_transport::CallError> for InterceptionError {
36 fn from(e: zendriver_transport::CallError) -> Self {
37 Self::Call(Box::new(e))
38 }
39}
40
41#[cfg(test)]
42#[allow(clippy::panic, clippy::unwrap_used)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn display_invalid_pattern() {
48 let e = InterceptionError::InvalidPattern("**bad".into());
49 assert_eq!(e.to_string(), "invalid url pattern: **bad");
50 }
51}