Skip to content

Commit

Permalink
fix(test): Improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 23, 2022
1 parent 4d7d2e9 commit 384ebac
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/decoded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ pub enum Decoded {

impl Decoded {
pub fn from_slice(v: &[u8]) -> Result<Self, crate::Error> {
serde_json::from_slice(v).map_err(crate::Error::new)
serde_json::from_slice(v).map_err(|e| {
crate::Error::new(format!(
"failed decoding: {}\n```json\n{}\n```",
e,
String::from_utf8_lossy(v)
))
})
}

pub fn to_string_pretty(&self) -> Result<String, crate::Error> {
Expand Down

0 comments on commit 384ebac

Please sign in to comment.