Skip to main content

onspring/
error.rs

1/// Errors that can occur when using the Onspring API client.
2#[derive(Debug, thiserror::Error)]
3pub enum OnspringError {
4  /// An HTTP transport error occurred.
5  #[error("HTTP request failed: {0}")]
6  Http(#[from] reqwest::Error),
7
8  /// The API returned a non-success status code.
9  #[error("API error (status {status_code}): {message}")]
10  Api { status_code: u16, message: String },
11
12  /// A serialization or deserialization error occurred.
13  #[error("Serialization error: {0}")]
14  Serialization(#[from] serde_json::Error),
15
16  /// An invalid argument was provided to an SDK method.
17  #[error("Invalid argument: {0}")]
18  InvalidArgument(String),
19}
20
21/// A type alias for `Result<T, OnspringError>`.
22pub type Result<T> = std::result::Result<T, OnspringError>;