Remove EppCommandResponseError alias

This is a direct alias for EppCommandResponse. It is documented
as marking an error state, but type aliases aren't a great tool
for that because the type system doesn't distinguish aliased types;
if we want to do that seriously it should be a newtype wrapper.
This commit is contained in:
Dirkjan Ochtman 2021-12-02 13:42:56 +01:00 committed by masalachai
parent f6ec331227
commit 91070576cd
3 changed files with 5 additions and 7 deletions

View File

@ -1,13 +1,13 @@
//! Error types to wrap internal errors and make EPP errors easier to read //! Error types to wrap internal errors and make EPP errors easier to read
use crate::response::EppCommandResponseError; use crate::response::EppCommandResponse;
use std::fmt::Display; use std::fmt::Display;
/// Error enum holding the possible error types /// Error enum holding the possible error types
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
EppConnectionError(std::io::Error), EppConnectionError(std::io::Error),
EppCommandError(EppCommandResponseError), EppCommandError(EppCommandResponse),
EppDeserializationError(String), EppDeserializationError(String),
Other(String), Other(String),
} }
@ -15,7 +15,7 @@ pub enum Error {
/// An EPP XML error /// An EPP XML error
#[derive(Debug)] #[derive(Debug)]
pub struct EppCommandError { pub struct EppCommandError {
pub epp_error: EppCommandResponseError, pub epp_error: EppCommandResponse,
} }
impl std::error::Error for Error {} impl std::error::Error for Error {}

View File

@ -8,8 +8,6 @@ use crate::common::{ElementName, EppObject, Extension, StringValue};
/// A generic EPP Response to an EPP command with a result section, a status code and a message /// A generic EPP Response to an EPP command with a result section, a status code and a message
pub type EppCommandResponse = EppObject<CommandResponseStatus>; pub type EppCommandResponse = EppObject<CommandResponseStatus>;
/// An alias of `EppCommandResponse` indicating an EPP Error
pub type EppCommandResponseError = EppCommandResponse;
/// Type corresponding to the <undef> tag an EPP response XML /// Type corresponding to the <undef> tag an EPP response XML
#[derive(Serialize, Deserialize, Debug, PartialEq)] #[derive(Serialize, Deserialize, Debug, PartialEq)]

View File

@ -35,7 +35,7 @@ mod response {
use crate::message::ack::MessageAck; use crate::message::ack::MessageAck;
use crate::message::poll::MessagePoll; use crate::message::poll::MessagePoll;
use crate::request::EppRequest; use crate::request::EppRequest;
use crate::response::EppCommandResponseError; use crate::response::EppCommandResponse;
use crate::xml::EppXml; use crate::xml::EppXml;
const SVTRID: &str = "RO-6879-1627224678242975"; const SVTRID: &str = "RO-6879-1627224678242975";
@ -75,7 +75,7 @@ mod response {
#[test] #[test]
fn error() { fn error() {
let xml = get_xml("response/error.xml").unwrap(); let xml = get_xml("response/error.xml").unwrap();
let object = EppCommandResponseError::deserialize(xml.as_str()).unwrap(); let object = EppCommandResponse::deserialize(xml.as_str()).unwrap();
assert_eq!(object.data.result.code, 2303); assert_eq!(object.data.result.code, 2303);
assert_eq!(object.data.result.message, "Object does not exist".into()); assert_eq!(object.data.result.message, "Object does not exist".into());