wait_human/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when using the WaitHuman client
4#[derive(Error, Debug)]
5pub enum WaitHumanError {
6    /// Request timed out waiting for an answer
7    #[error("Request timed out after {elapsed_seconds:.1} seconds")]
8    Timeout { elapsed_seconds: f64 },
9
10    /// Network error occurred during HTTP request
11    #[error("Network error: {0}")]
12    NetworkError(#[from] reqwest::Error),
13
14    /// Failed to create confirmation request
15    #[error("Failed to create confirmation: {status_text}")]
16    CreateFailed { status_text: String },
17
18    /// Failed to poll for answer
19    #[error("Failed to poll for answer: {status_text}")]
20    PollFailed { status_text: String },
21
22    /// Received unexpected answer type
23    #[error("Unexpected answer type: expected {expected}, got {actual}")]
24    UnexpectedAnswerType { expected: String, actual: String },
25
26    /// Invalid selected index in answer
27    #[error("Invalid selected index: {index}")]
28    InvalidSelectedIndex { index: u32 },
29
30    /// Invalid response from server
31    #[error("Invalid response from server: {0}")]
32    InvalidResponse(String),
33}
34
35/// Result type alias for WaitHuman operations
36pub type Result<T> = std::result::Result<T, WaitHumanError>;