Skip to content

Commit

Permalink
Add context to Error::DecodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
Ortham committed Nov 25, 2023
1 parent 7308716 commit 465fa3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub enum Error {
NoFilename,
ParsingIncomplete,
ParsingError(Vec<u8>, ParsingErrorKind),
DecodeError,
DecodeError(Vec<u8>),
}

impl From<Err<nom::error::Error<&[u8]>>> for Error {
Expand Down Expand Up @@ -61,9 +61,9 @@ impl fmt::Display for Error {
"An error was encountered while parsing the plugin content {:02X?}: {}",
input, kind
),
Error::DecodeError => write!(
Error::DecodeError(bytes) => write!(
f,
"Plugin string content could not be decoded from Windows-1252"
"Plugin string content could not be decoded from Windows-1252, bytes are {bytes:02X?}"
),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl Plugin {
return WINDOWS_1252
.decode_without_bom_handling_and_without_replacement(data)
.map(|s| Some(s.to_string()))
.ok_or(Error::DecodeError);
.ok_or(Error::DecodeError(data.to_vec()));
}
}

Expand Down Expand Up @@ -455,7 +455,7 @@ fn masters(header_record: &Record) -> Result<Vec<String>, Error> {
WINDOWS_1252
.decode_without_bom_handling_and_without_replacement(d)
.map(|s| s.to_string())
.ok_or(Error::DecodeError)
.ok_or(Error::DecodeError(d.to_vec()))
})
.collect::<Result<Vec<String>, Error>>()
}
Expand Down

0 comments on commit 465fa3d

Please sign in to comment.