Skip to main content

voip_ms/
error.rs

1/// Result type returned by all [`Client`](crate::Client) methods.
2pub type Result<T> = std::result::Result<T, Error>;
3
4/// The [`ApiStatus`] enum and its impls are generated from the official API
5/// docs' error-code table; see [`crate::generated`].
6pub use crate::generated::ApiStatus;
7
8/// Errors returned by the VoIP.ms client.
9#[derive(Debug, thiserror::Error)]
10pub enum Error {
11    /// Transport or HTTP-level failure.
12    #[error("HTTP error: {0}")]
13    Http(#[from] reqwest::Error),
14
15    /// The response did not contain the expected JSON envelope.
16    #[error("invalid response: {0}")]
17    InvalidResponse(String),
18
19    /// The API responded with a non-`success` status, surfaced as a typed
20    /// [`ApiStatus`] variant (or [`ApiStatus::Unknown`] for a code this crate
21    /// doesn't recognize).
22    #[error("API status: {0}")]
23    Api(ApiStatus),
24}