Skip to main content

veil_sdk/
error.rs

1use thiserror::Error;
2
3/// All errors the SDK can return.
4#[derive(Debug, Error)]
5pub enum VeilError {
6    /// Network or transport-level failure.
7    #[error("HTTP error: {0}")]
8    Http(#[from] reqwest::Error),
9
10    /// The gateway returned a non-2xx status with an error body.
11    #[error("gateway error {status}: {message}")]
12    Api { status: u16, message: String },
13
14    /// Polling timed out before the job reached a terminal state.
15    #[error("job {job_id} timed out after {elapsed_ms}ms (last status: {last_status})")]
16    Timeout {
17        job_id: String,
18        elapsed_ms: u64,
19        last_status: String,
20    },
21
22    /// The gateway reported the job as failed.
23    #[error("job {job_id} failed: {}", reason.as_deref().unwrap_or("no reason given"))]
24    JobFailed {
25        job_id: String,
26        reason: Option<String>,
27    },
28
29    /// The gateway URL is not valid.
30    #[error("invalid base URL: {0}")]
31    InvalidUrl(String),
32
33    /// Response body could not be parsed.
34    #[error("failed to deserialise response: {0}")]
35    Deserialize(#[from] serde_json::Error),
36}
37
38pub type Result<T> = std::result::Result<T, VeilError>;