pub enum HetznerError {
Show 14 variants
Http(Error),
Api {
code: String,
message: String,
},
NotFound {
resource_type: String,
identifier: String,
},
AlreadyExists {
resource_type: String,
name: String,
},
InvalidParameter {
parameter: String,
reason: String,
},
Validation(String),
Timeout {
operation: String,
timeout_secs: u64,
},
Serialization(Error),
Unauthorized,
Forbidden {
details: String,
},
RateLimited {
retry_after: Option<u64>,
},
ServerError {
status_code: u16,
details: String,
},
InvalidToken(String),
BuilderError(String),
}Expand description
Comprehensive error type for Hetzner Cloud API operations.
This error type provides detailed context about what went wrong, including HTTP status codes, API error details, and contextual information.
§Examples
use lmrc_hetzner::{HetznerClient, HetznerError};
let client = HetznerClient::builder()
.api_token("your-token".to_string())
.build()?;
match client.get::<serde_json::Value>("/servers").await {
Ok(servers) => println!("Got servers: {:?}", servers),
Err(HetznerError::Unauthorized) => {
eprintln!("Invalid API token");
}
Err(HetznerError::RateLimited { retry_after }) => {
eprintln!("Rate limited, retry after: {:?}", retry_after);
}
Err(e) => eprintln!("Other error: {}", e),
}Variants§
Http(Error)
HTTP request failed due to network or connection issues.
This typically indicates network problems, DNS failures, or connection timeouts.
Api
Hetzner API returned an error response.
Contains the error code and message from the API.
Fields
NotFound
The requested resource was not found (HTTP 404).
This could mean the resource doesn’t exist or was already deleted.
Fields
AlreadyExists
Resource already exists with the same name (HTTP 409).
Fields
InvalidParameter
Invalid input parameter or configuration.
§Examples
use lmrc_hetzner::HetznerError;
let err = HetznerError::InvalidParameter {
parameter: "ip_range".to_string(),
reason: "Must be a valid CIDR notation (e.g., 10.0.0.0/16)".to_string(),
};Fields
Validation(String)
Validation failed for input data.
Timeout
Operation timed out waiting for completion.
Fields
Serialization(Error)
JSON serialization or deserialization failed.
Authentication failed (HTTP 401).
Usually indicates an invalid or expired API token.
Forbidden
Permission denied (HTTP 403).
The API token is valid but lacks permission for this operation.
RateLimited
Rate limit exceeded (HTTP 429).
The API has rate limits. Wait before retrying.
ServerError
Server error from Hetzner API (HTTP 5xx).
InvalidToken(String)
Invalid API token format.
BuilderError(String)
Builder configuration error.
Trait Implementations§
Source§impl Debug for HetznerError
impl Debug for HetznerError
Source§impl Display for HetznerError
impl Display for HetznerError
Source§impl Error for HetznerError
impl Error for HetznerError
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
Source§impl From<Error> for HetznerError
impl From<Error> for HetznerError
Auto Trait Implementations§
impl Freeze for HetznerError
impl !RefUnwindSafe for HetznerError
impl Send for HetznerError
impl Sync for HetznerError
impl Unpin for HetznerError
impl !UnwindSafe for HetznerError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.