Skip to content

Commit

Permalink
remove panic for wrong file data
Browse files Browse the repository at this point in the history
  • Loading branch information
kilork committed Nov 18, 2019
1 parent 0830c59 commit 8abcffc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pub enum ErrorKind {
IO(std::io::Error),
#[fail(display = "verify error {}", _0)]
VerifyFailure(String),
#[fail(display = "wrong file data {}", _0)]
WrongFileData(String),
#[fail(
display = "wrong name of Mercurial user '{}'.
Must be in form 'Username <[email protected]>'.
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,11 @@ impl<'a> MercurialRepo<'a> {
writeln!(output, "\ndata {}", data.len())?;
output.write_all(&data[..])?;
}
_ => panic!("Wrong file data!"),
_ => {
return Err(ErrorKind::WrongFileData(
String::from_utf8_lossy(&file.path).into(),
))
}
}
}

Expand Down

0 comments on commit 8abcffc

Please sign in to comment.