Skip to main content

enphase_api/
error.rs

1//! # Error types for the Enphase API client
2//!
3//! This module contains all error types and handling for the Enphase API
4//! client.
5
6/// Error types that can occur when using the Enphase API client.
7#[derive(Debug, thiserror::Error)]
8#[non_exhaustive]
9pub enum EnphaseError {
10    /// HTTP request error from reqwest.
11    #[error("HTTP request failed: {0}")]
12    Http(#[from] reqwest::Error),
13
14    /// Invalid response from the API.
15    #[error("Invalid API response: {0}")]
16    InvalidResponse(String),
17
18    /// Authentication failed.
19    #[error("Authentication failed: {0}")]
20    AuthenticationFailed(String),
21
22    /// Configuration error.
23    #[error("Configuration error: {0}")]
24    ConfigurationError(String),
25
26    /// I/O error.
27    #[error("I/O error: {0}")]
28    IoError(#[from] std::io::Error),
29
30    /// JSON parsing error.
31    #[error("JSON parsing error: {0}")]
32    JsonError(#[from] serde_json::Error),
33}
34
35/// Result type for Enphase API operations.
36pub type Result<T> = core::result::Result<T, EnphaseError>;