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
use crate::response::EppCommandResponseError;
use crate::response::EppCommandResponse;
use std::fmt::Display;
/// Error enum holding the possible error types
#[derive(Debug)]
pub enum Error {
EppConnectionError(std::io::Error),
EppCommandError(EppCommandResponseError),
EppCommandError(EppCommandResponse),
EppDeserializationError(String),
Other(String),
}
@ -15,7 +15,7 @@ pub enum Error {
/// An EPP XML error
#[derive(Debug)]
pub struct EppCommandError {
pub epp_error: EppCommandResponseError,
pub epp_error: EppCommandResponse,
}
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
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
#[derive(Serialize, Deserialize, Debug, PartialEq)]

View File

@ -35,7 +35,7 @@ mod response {
use crate::message::ack::MessageAck;
use crate::message::poll::MessagePoll;
use crate::request::EppRequest;
use crate::response::EppCommandResponseError;
use crate::response::EppCommandResponse;
use crate::xml::EppXml;
const SVTRID: &str = "RO-6879-1627224678242975";
@ -75,7 +75,7 @@ mod response {
#[test]
fn error() {
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.message, "Object does not exist".into());