Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ impl From<OddLengthStringError> for HexToBytesError {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InvalidCharError {
pub(crate) invalid: u8,
pub(crate) pos: usize,
}

impl InvalidCharError {
/// Returns the invalid character byte.
pub fn invalid_char(&self) -> u8 { self.invalid }
/// Returns the position of the invalid character byte.
pub fn pos(&self) -> usize { self.pos }
}

impl fmt::Display for InvalidCharError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "invalid hex char {}", self.invalid)
write!(f, "invalid hex char {} at pos {}", self.invalid, self.pos)
}
}

Expand Down
Loading