Skip to content

Commit 2dc0296

Browse files
Merge pull request #143 from marshallpierce/mp/invalid-length-doc
Add a note for InvalidLength explaining that trailing whitespace is a…
2 parents 4509575 + 4547118 commit 2dc0296

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/decode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ pub enum DecodeError {
2929
/// An invalid byte was found in the input. The offset and offending byte are provided.
3030
InvalidByte(usize, u8),
3131
/// The length of the input is invalid.
32+
/// A typical cause of this is stray trailing whitespace or other separator bytes.
3233
InvalidLength,
3334
/// The last non-padding input symbol's encoded 6 bits have nonzero bits that will be discarded.
3435
/// This is indicative of corrupted or truncated Base64.
@@ -43,7 +44,7 @@ impl fmt::Display for DecodeError {
4344
DecodeError::InvalidByte(index, byte) => {
4445
write!(f, "Invalid byte {}, offset {}.", byte, index)
4546
}
46-
DecodeError::InvalidLength => write!(f, "Encoded text cannot have a 6-bit remainder."),
47+
DecodeError::InvalidLength => write!(f, "Encoded text cannot have a 6-bit remainder. Trailing whitespace or other bytes?"),
4748
DecodeError::InvalidLastSymbol(index, byte) => {
4849
write!(f, "Invalid last symbol {}, offset {}.", byte, index)
4950
}

0 commit comments

Comments
 (0)