pub enum MoonError {
Middleware(String),
Network(String),
Parse(Error),
Io(Error),
ApiValidation(ApiErrors),
ApiError {
code: u16,
message: String,
},
Config(String),
ResponseDecode {
error_message: String,
raw: String,
},
Unauthorized(String),
ValidationError(String),
Unknown,
}Expand description
Primary error type for the moonclient core framework.
Encapsulates transport-level network faults, parsing discrepancies, I/O failures, and API validation errors. External dependency types are converted into stable internal representations, guaranteeing public API stability.
Variants§
Middleware(String)
Failure originated within the internal middleware pipeline.
Typically triggered by retry policy exhaustion, rate limiters, or tracing failures.
Network(String)
Transport-level network failure.
Occurs during connection drops, DNS resolution failures, timeouts, or physical transport disconnects.
Parse(Error)
Serialization or deserialization failure.
Caused by payload schema mismatches against expected serde structures.
Io(Error)
Filesystem input/output error.
Occurs when failing to read or persist session caches, disk stores, or encountering file permission violations.
ApiValidation(ApiErrors)
Specific remote API validation failure (HTTP 422 Unprocessable Entity).
Carries detailed per-field validation violation maps or flat message vectors.
ApiError
Standard HTTP error status returned by the remote server (HTTP 4xx, 5xx).
Used for non-422 status codes (e.g., 404 Not Found, 502 Bad Gateway).
Fields
Config(String)
Network client configuration error.
Triggered by invalid rate limiter parameters, malformed base URLs, or missing required state components.
ResponseDecode
Response deserialization failure with bounded raw payload preservation for debugging.
Prevents raw payload loss during deserialization crashes, allowing developers to inspect the unparseable payload fragment in logs.
Fields
error_message: StringTextual error description provided by serde_json.
Local client authorization failure.
Triggered when attempting to invoke authenticated endpoints without an active session in memory.
ValidationError(String)
Local client-side parameter validation error.
Preemptively prevents dispatching obviously invalid requests, saving bandwidth and rate limits.
Unknown
Unforeseen internal system failure.
Trait Implementations§
Source§impl Error for MoonError
impl Error for MoonError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for MoonError
impl From<Error> for MoonError
Source§fn from(err: Error) -> Self
fn from(err: Error) -> Self
Converts a reqwest_middleware::Error
into a stable MoonError::Middleware.
§Arguments
err(reqwest_middleware::Error) — Middleware pipeline error.
§Returns
A standardized MoonError::Middleware variant.
Source§impl From<Error> for MoonError
impl From<Error> for MoonError
Source§fn from(err: Error) -> Self
fn from(err: Error) -> Self
Converts a reqwest::Error
into a stable MoonError::Network.
§Arguments
err(reqwest::Error) — Transport or protocol error from reqwest.
§Returns
A standardized MoonError::Network variant.
Source§impl From<Error> for MoonError
impl From<Error> for MoonError
Source§fn from(err: Error) -> Self
fn from(err: Error) -> Self
Converts an std::io::Error
into a MoonError::Io.
§Arguments
err(std::io::Error) — Low-level filesystem or stream I/O error.
§Returns
A standardized MoonError::Io variant.