From 78628cfc02c792e8235d3160af0435f3ab1bdee2 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 7 Dec 2021 11:20:27 +0100 Subject: [PATCH] Rename Error variants to avoid stuttering --- src/error.rs | 12 ++++++------ src/request.rs | 2 +- src/xml.rs | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/error.rs b/src/error.rs index 79076a8..8037d17 100644 --- a/src/error.rs +++ b/src/error.rs @@ -6,9 +6,9 @@ use std::fmt::Display; /// Error enum holding the possible error types #[derive(Debug)] pub enum Error { - EppConnectionError(std::io::Error), - EppCommandError(ResponseStatus), - EppDeserializationError(String), + Io(std::io::Error), + Command(ResponseStatus), + Deserialize(String), Other(String), } @@ -17,7 +17,7 @@ impl std::error::Error for Error {} impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Error::EppCommandError(e) => { + Error::Command(e) => { write!(f, "epp-client EppCommandError: {}", e.result.message) } Error::Other(e) => write!(f, "epp-client Exception: {}", e), @@ -34,12 +34,12 @@ impl From> for Error { impl From for Error { fn from(e: std::io::Error) -> Self { - Self::EppConnectionError(e) + Self::Io(e) } } impl From for Error { fn from(e: std::io::ErrorKind) -> Self { - Self::EppConnectionError(std::io::Error::from(e)) + Self::Io(std::io::Error::from(e)) } } diff --git a/src/request.rs b/src/request.rs index 624c5c4..8d49cad 100644 --- a/src/request.rs +++ b/src/request.rs @@ -34,7 +34,7 @@ pub trait Transaction: Command + Sized { as EppXml>::deserialize(epp_xml)?; match rsp.data.result.code { 0..=2000 => Ok(rsp.data), - _ => Err(crate::error::Error::EppCommandError(ResponseStatus { + _ => Err(crate::error::Error::Command(ResponseStatus { result: rsp.data.result, tr_ids: rsp.data.tr_ids, })), diff --git a/src/xml.rs b/src/xml.rs index 8f262fa..af0743a 100644 --- a/src/xml.rs +++ b/src/xml.rs @@ -29,7 +29,7 @@ pub trait EppXml: Sized { let object: Self = match from_str(epp_xml) { Ok(v) => v, Err(e) => { - return Err(error::Error::EppDeserializationError(format!( + return Err(error::Error::Deserialize(format!( "epp-client Deserialization Error: {}", e )))