1use asterisk_rs_core::error::ProtocolError;
2
3#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum AgiError {
7 #[error("I/O error: {0}")]
8 Io(#[from] std::io::Error),
9
10 #[error("channel hung up during AGI session")]
11 ChannelHungUp,
12
13 #[error("invalid AGI response: {raw}")]
14 InvalidResponse { raw: String },
15
16 #[error("AGI command failed with code {code}: {message}")]
17 CommandFailed { code: u16, message: String },
18
19 #[error("invalid AGI argument: {details}")]
20 InvalidArgument { details: String },
21
22 #[error("command already in flight; channel is not cancel-safe")]
23 CommandInFlight,
24
25 #[error("channel is poisoned due to a previous I/O error")]
26 ChannelPoisoned,
27
28 #[error("protocol error: {0}")]
29 Protocol(#[from] ProtocolError),
30}
31
32pub type Result<T> = std::result::Result<T, AgiError>;