Skip to main content

mountos_admin_sdk/
errors.rs

1//! Error type returned by all SDK operations.
2
3/// An error from the mountOS Admin API or the transport beneath it.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum Error {
7    /// The API returned a non-success envelope (`status != "success"`).
8    #[error("mountos: {message} (status={status}, code={error_code})")]
9    Api {
10        /// Human-readable message from the API.
11        message: String,
12        /// HTTP status code.
13        status: u16,
14        /// mountOS application error code (0 when absent).
15        error_code: i64,
16    },
17
18    /// The HTTP request failed (connection, timeout, TLS, ...).
19    #[error("mountos: http transport error: {0}")]
20    Http(#[from] reqwest::Error),
21
22    /// A request or response body could not be (de)serialized.
23    #[error("mountos: serialization error: {0}")]
24    Serde(#[from] serde_json::Error),
25
26    /// The configured private key could not be parsed.
27    #[error("mountos: invalid private key: {0}")]
28    Key(String),
29}