nle_cloud_sdk/error.rs
1//! Error types and Result alias for the NLECloud SDK.
2
3use thiserror::Error;
4
5/// Errors that can occur when using the NLECloud SDK.
6#[derive(Error, Debug)]
7pub enum SdkError {
8 /// An HTTP transport error occurred.
9 #[error("HTTP error: {0}")]
10 Http(#[from] reqwest::Error),
11
12 /// A JSON serialization or deserialization error occurred.
13 #[error("JSON error: {0}")]
14 Json(#[from] serde_json::Error),
15
16 /// A URL parsing error occurred.
17 #[error("URL parse error: {0}")]
18 Url(#[from] url::ParseError),
19
20 /// The API responded with a logical failure status in its ResultMsg envelope.
21 #[error("NLECloud API error (status: {status}): {message}")]
22 Api {
23 /// Upstream API error status code (non-zero indicates error).
24 status: i32,
25 /// Upstream error message or description.
26 message: String,
27 },
28
29 /// An authentication token is missing or invalid.
30 #[error("Authentication error: {0}")]
31 Authentication(String),
32
33 /// An invalid parameter was supplied.
34 #[error("Invalid parameter: {0}")]
35 InvalidParameter(String),
36
37 /// The API response format was unexpected or could not be parsed.
38 #[error("Unexpected response error: {0}")]
39 UnexpectedResponse(String),
40}
41
42/// Convenience type alias for SDK results.
43pub type Result<T> = std::result::Result<T, SdkError>;