Uh oh!
There was an error while loading. Please reload this page.
std::io: New ErrorKind value InvalidData - #25246
Conversation
rust-highfive
commented
May 9, 2015
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
mzabaluev
commented
May 9, 2015
This is a PR for rust-lang/rfcs#906. |
mzabaluev
commented
May 9, 2015
To bikeshed a bit more, I'd rename |
There was a problem hiding this comment.
This should probably stay as-is. CString::new returns a NulError when its argument (input) contains a null.
There was a problem hiding this comment.
The character data may have come from outside the program. In general, it's not a programming error for strings to contain null bytes, so to me it belongs in the same class of data conversion failures as, say, encountering malformed UTF-8 in an input operation that reads to a string.
alexcrichton
commented
May 12, 2015
I'm not sure I personally understand the distinction here, it seems like selecting one or the other can be ambiguous from time to time and the distinction may not actually carry much weight in the wild. Could you elaborate a little more on how these two are distinct and how they should be interpreted separately? |
alexcrichton
commented
May 12, 2015
cc @aturon |
mzabaluev
commented
May 13, 2015
@alexcrichton Other than data format errors, |
alexcrichton
commented
May 13, 2015
Hm I guess to me those seem like very similar classes of errors as they're both "invalid inputs" to the function. I think that |
mzabaluev
commented
May 14, 2015
|
mzabaluev
commented
May 14, 2015
#25406 is an alternative change where, conversely, the invalid-parameter cases are reclassified from |
aturon
commented
May 14, 2015
FWIW, I agree that it would be good to have distinct errors for "You passed in arguments that broke the contract" versus "The OS returned some data that was not in the expected form". I'm not in love with I also agree with others that the |
bluss
commented
May 14, 2015
When we are decoding a stream of text, it's invalid input to the program, not output. |
aturon
commented
May 14, 2015
The error variant is relative to the operation being performed, not the broader context of the program. We need the pair of variants to clearly signify whether the problem was with the arguments passed to the operation (InvalidInput) or with the data produced by the operation (hence InvalidOutput). |
Following some bikeshedding on PR rust-lang#25246.
mzabaluev
commented
May 17, 2015
I have updated the branch, thanks for your input. In my personal opinion, there is still potential for confusion between |
bluss
commented
May 17, 2015
My head is spinning. Run this past a bit more people to see what they think? Why do we use the terms Input / Output when we don't mean I/O? 😄 InvalidParameter, InvalidArgument, anything like that is better. W.r.t if data we process using the APIs is regarded as output from something else or input to us, or the reverse, that I don't know. I suggest just saying data for that, hence InvalidData. |
aturon
commented
May 18, 2015
The usage here is just the notion of arguments being "input" to a function, and the results it produces being its "output". Admittedly, InvalidArgument and InvalidResult would probably be more clear, but that would require a breaking change. |
aturon
commented
May 19, 2015
OK, after talking to @alexcrichton for a while, and stewing a bit more on the comments here, I think @bluss is right and the names |
bluss
commented
May 19, 2015
I would be happier. Consider that we use |
mzabaluev
commented
May 21, 2015
Rebased and condensed into one commit. |
There was a problem hiding this comment.
This stability tag should now say 1.1.0, and the feature name can be something like io_invalid_data.
Could you also expand the docs here a bit to clarify what InvalidData means with respect to InvalidInput?
There was a problem hiding this comment.
Sorry, I have copy-pasted it without thinking.
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.
mzabaluev
commented
May 29, 2015
Updated and rebased the commit, now with a more descriptive doc text and corrected stability attribute. |
There was a problem hiding this comment.
Gah oops, sorry but I forgot we've entered 1.2 territory at this point, so this should actually be 1.2 instead of 1.1. Other than that though this looks good to me!
mzabaluev
commented
May 31, 2015
Note that this is, strictly speaking, a breaking change: error-handling code that matches for |
alexcrichton
commented
Jun 1, 2015
bors
commented
Jun 1, 2015
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. Fixesrust-lang/rfcs#906
bors
commented
Jun 1, 2015
💔 Test failed - auto-linux-64-opt |
alexcrichton
commented
Jun 1, 2015
@bors: retry On Mon, Jun 1, 2015 at 11:57 AM, bors notifications@github.com wrote:
|
bors
commented
Jun 1, 2015
⚡ Previous build results for auto-linux-32-nopt-t, auto-linux-64-nopt-t, auto-linux-64-x-android-t, auto-mac-32-opt, auto-mac-64-nopt-t, auto-mac-64-opt, auto-win-gnu-32-nopt-t, auto-win-gnu-32-opt, auto-win-gnu-64-nopt-t, auto-win-gnu-64-opt are reusable. Rebuilding only auto-linux-32-opt, auto-linux-64-opt... |
alexcrichton
commented
Jun 1, 2015
@bors: retry clean force |
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. Fixesrust-lang/rfcs#906
This takes the cases from
InvalidInputwhere a data format errorwas encountered. This is different from the documented semantics
of
InvalidInput, which more likely indicate a programming error.Fixesrust-lang/rfcs#906