diff --git a/src/cfdp/mod.rs b/src/cfdp/mod.rs index d7df6e1..09f2241 100644 --- a/src/cfdp/mod.rs +++ b/src/cfdp/mod.rs @@ -193,11 +193,11 @@ pub struct InvalidTlvTypeFieldError { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum TlvLvError { - #[error("TLV/LV error: {0}")] + #[error("{0}")] DataTooLarge(#[from] TlvLvDataTooLargeError), - #[error("TLV/LV error: {0}")] + #[error("byte conversion error: {0}")] ByteConversion(#[from] ByteConversionError), - #[error("TLV/LV error: {0}")] + #[error("{0}")] InvalidTlvTypeField(#[from] InvalidTlvTypeFieldError), #[error("invalid value length {0}")] InvalidValueLength(usize), diff --git a/src/cfdp/pdu/metadata.rs b/src/cfdp/pdu/metadata.rs index 55731da..a63e11c 100644 --- a/src/cfdp/pdu/metadata.rs +++ b/src/cfdp/pdu/metadata.rs @@ -780,7 +780,7 @@ pub mod tests { assert_eq!(expected, Some(FileDirectiveType::MetadataPdu)); assert_eq!( error.to_string(), - "invalid directive type value 255, expected Some(MetadataPdu)" + "invalid directive type, found 255, expected Some(MetadataPdu)" ); } else { panic!("Expected InvalidDirectiveType error, got {:?}", error); @@ -806,7 +806,7 @@ pub mod tests { assert_eq!(expected, FileDirectiveType::MetadataPdu); assert_eq!( error.to_string(), - "found directive type EofPdu, expected MetadataPdu" + "wrong directive type, found EofPdu, expected MetadataPdu" ); } else { panic!("Expected InvalidDirectiveType error, got {:?}", error); diff --git a/src/cfdp/pdu/mod.rs b/src/cfdp/pdu/mod.rs index 0817f03..4f6eef3 100644 --- a/src/cfdp/pdu/mod.rs +++ b/src/cfdp/pdu/mod.rs @@ -31,18 +31,18 @@ pub enum FileDirectiveType { #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum PduError { - #[error("PDU error: {0}")] + #[error("byte conversion error: {0}")] ByteConversion(#[from] ByteConversionError), /// Found version ID invalid, not equal to [super::CFDP_VERSION_2]. - #[error("CFDP version missmatch {0}")] + #[error("CFDP version missmatch, found {0}, expected {ver}", ver = super::CFDP_VERSION_2)] CfdpVersionMissmatch(u8), /// Invalid length for the entity ID detected. Only the values 1, 2, 4 and 8 are supported. - #[error("invalid entity ID length {0}")] + #[error("invalid PDU entity ID length {0}, only [1, 2, 4, 8] are allowed")] InvalidEntityLen(u8), /// Invalid length for the entity ID detected. Only the values 1, 2, 4 and 8 are supported. #[error("invalid transaction ID length {0}")] InvalidTransactionSeqNumLen(u8), - #[error("source ID length {src_id_len} and destination ID length {dest_id_len} missmatch")] + #[error("missmatch of PDU source ID length {src_id_len} and destination ID length {dest_id_len}")] SourceDestIdLenMissmatch { src_id_len: usize, dest_id_len: usize, @@ -61,7 +61,7 @@ pub enum PduError { found: u8, expected: Option, }, - #[error("invalid start or end of scope value")] + #[error("invalid start or end of scope value for NAK PDU")] InvalidStartOrEndOfScopeValue, /// Invalid condition code. Contains the raw detected value. #[error("invalid condition code {0}")] @@ -901,7 +901,7 @@ mod tests { assert_eq!(raw_version, CFDP_VERSION_2 + 1); assert_eq!( error.to_string(), - "cfdp version missmatch, found 2, expected 1" + "CFDP version missmatch, found 2, expected 1" ); } else { panic!("invalid exception: {}", error); @@ -949,7 +949,7 @@ mod tests { assert_eq!(expected, 7); assert_eq!( error.to_string(), - "source slice with size 6 too small, expected at least 7 bytes" + "byte conversion error: source slice with size 6 too small, expected at least 7 bytes" ); } } @@ -1004,7 +1004,7 @@ mod tests { assert_eq!(dest_id_len, 2); assert_eq!( error.to_string(), - "missmatch of PDU source length 1 and destination length 2" + "missmatch of PDU source ID length 1 and destination ID length 2" ); } } diff --git a/src/cfdp/pdu/nak.rs b/src/cfdp/pdu/nak.rs index f53d38f..0c9aedc 100644 --- a/src/cfdp/pdu/nak.rs +++ b/src/cfdp/pdu/nak.rs @@ -751,7 +751,7 @@ mod tests { if let PduError::InvalidStartOrEndOfScopeValue = error { assert_eq!( error.to_string(), - "invalid start or end of scope for NAK PDU" + "invalid start or end of scope value for NAK PDU" ); } else { panic!("unexpected error {error}"); diff --git a/src/cfdp/tlv/mod.rs b/src/cfdp/tlv/mod.rs index 026b7a4..bb4973d 100644 --- a/src/cfdp/tlv/mod.rs +++ b/src/cfdp/tlv/mod.rs @@ -1043,14 +1043,14 @@ mod tests { let tlv_res = Tlv::new(TlvType::MsgToUser, &buf_too_large); assert!(tlv_res.is_err()); let error = tlv_res.unwrap_err(); - if let TlvLvError::DataTooLarge(data_too_large) = error { - assert_eq!(data_too_large.0, u8::MAX as usize + 1); - assert_eq!( - error.to_string(), - "data with size 256 larger than allowed 255 bytes" - ); - } else { - panic!("unexpected error {:?}", error); + match error { + TlvLvDataTooLargeError(size) => { + assert_eq!(size, u8::MAX as usize + 1); + assert_eq!( + error.to_string(), + "data with size 256 larger than allowed 255 bytes" + ); + } } }