Files
pmomusic/pmoupnp/src/services/errors.rs

62 lines
1.7 KiB
Rust
Raw Normal View History

2025-10-05 14:35:44 +02:00
//! Erreurs du module services.
2025-10-02 18:39:32 +02:00
use thiserror::Error;
2025-10-05 14:35:44 +02:00
/// Erreurs liées aux services UPnP.
///
/// Cette énumération couvre toutes les erreurs possibles lors de la manipulation
/// de services UPnP, incluant les erreurs de validation, de configuration et d'exécution.
2025-10-02 18:39:32 +02:00
#[derive(Error, Debug)]
pub enum ServiceError {
2025-10-05 14:35:44 +02:00
/// Erreur générale du service.
#[error("Service error: {0}")]
2025-10-02 18:39:32 +02:00
GeneralError(String),
2025-10-05 14:35:44 +02:00
/// Erreur de validation (paramètres invalides).
#[error("Validation error: {0}")]
ValidationError(String),
2025-10-02 18:39:32 +02:00
2025-10-05 14:35:44 +02:00
/// Erreur lors d'une opération sur un ensemble (Set).
2025-10-02 18:39:32 +02:00
#[error("Set operation error: {0}")]
SetError(String),
2025-10-05 14:35:44 +02:00
/// Erreur liée à une action.
#[error("Action error: {0}")]
ActionError(String),
/// Erreur liée à une variable d'état.
#[error("State variable error: {0}")]
StateVariableError(String),
/// Erreur de configuration.
#[error("Configuration error: {0}")]
ConfigError(String),
/// Erreur réseau ou HTTP.
#[error("Network error: {0}")]
NetworkError(String),
/// Erreur de sérialisation XML.
#[error("XML serialization error: {0}")]
XmlError(String),
/// Erreur lors du traitement SOAP.
#[error("SOAP error: {0}")]
SoapError(String),
2025-10-02 18:39:32 +02:00
}
impl From<std::io::Error> for ServiceError {
fn from(err: std::io::Error) -> Self {
ServiceError::GeneralError(format!("IO error: {}", err))
}
2025-10-05 14:35:44 +02:00
}
impl From<crate::UpnpObjectSetError> for ServiceError {
fn from(err: crate::UpnpObjectSetError) -> Self {
match err {
crate::UpnpObjectSetError::AlreadyExists(name) => {
ServiceError::SetError(format!("Object already exists: {}", name))
}
}
}
2025-10-02 18:39:32 +02:00
}