Skip to content

Commit

Permalink
std::io: New ErrorKind value InvalidData
Browse files Browse the repository at this point in the history
This takes the cases from InvalidInput where a data format error
was encountered. This is different from the documented semantics
of InvalidInput, which more likely indicate a programming error.
  • Loading branch information
mzabaluev committed May 21, 2015
1 parent 4423748 commit 7d50cbc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/libstd/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ pub enum ErrorKind {
/// A parameter was incorrect.
#[stable(feature = "rust1", since = "1.0.0")]
InvalidInput,
/// Invalid data encountered.
#[stable(feature = "rust1", since = "1.0.0")]
InvalidData,
/// The I/O operation's timeout expired, causing it to be canceled.
#[stable(feature = "rust1", since = "1.0.0")]
TimedOut,
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn append_to_string<F>(buf: &mut String, f: F) -> Result<usize>
let ret = f(g.s);
if str::from_utf8(&g.s[g.len..]).is_err() {
ret.and_then(|_| {
Err(Error::new(ErrorKind::InvalidInput,
Err(Error::new(ErrorKind::InvalidData,
"stream did not contain valid UTF-8"))
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,5 @@ impl Output {
}

fn invalid_encoding() -> io::Error {
io::Error::new(io::ErrorKind::InvalidInput, "text was not valid unicode")
io::Error::new(io::ErrorKind::InvalidData, "text was not valid unicode")
}

0 comments on commit 7d50cbc

Please sign in to comment.