use std::backtrace::Backtrace;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ProxmoxError {
#[error("Connection error: {0}")]
Connection(String),
#[error("Authentication error: {0}")]
Authentication(String),
#[error("Validation error: {source}")]
Validation {
source: ValidationError,
#[backtrace]
backtrace: Backtrace,
},
}
impl From<ValidationError> for ProxmoxError {
fn from(error: ValidationError) -> Self {
ProxmoxError::Validation {
source: error,
backtrace: Backtrace::capture(),
}
}
}
#[derive(Error, Debug)]
pub enum ValidationError {
#[error("Field '{field}' validation failed: {message}")]
Field { field: String, message: String },
#[error("Format error: {0}")]
Format(String),
#[error("Domain constraint violation: {0}")]
ConstraintViolation(String),
}
pub type ProxmoxResult<T> = Result<T, ProxmoxError>;