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