Error kinds and limits shared by the streaming codecs of gaato/codecs.mbt.
moon add gaato/codec///|
/// What to tell the client that sent a compressed request body.
fn describe(error : @codec.CodecError) -> String {
match error.kind() {
LimitExceeded({ resource: Output, limit, .. }) =>
"the body is over \{limit} bytes once decompressed"
LimitExceeded(_) => "the body needs too much memory to decompress"
Truncated => "the body ends too early"
DictionaryRequired(_) | DictionaryMismatch =>
"the body needs a dictionary this server does not have"
_ => "the body is not valid"
}
}
///|
test "describe codec errors" {
let too_big = @codec.CodecError::CodecError(
LimitExceeded({ resource: Output, needed: None, limit: 1024, }),
"more than max_output bytes",
)
assert_eq(describe(too_big), "the body is over 1024 bytes once decompressed")
assert_eq(
describe(@codec.CodecError::CodecError(Truncated, "end of input")),
"the body ends too early",
)
}| Kind | Meaning |
|---|---|
| Truncated | The input ended inside a stream. |
| Corrupt | The input is not a valid stream. |
| ChecksumMismatch | A checksum, or a length the stream declares, does not match the data. |
| TrailingData | Bytes follow the end of the stream. |
| LimitExceeded(limit) | Going on would pass a limit. limit names the resource (Memory or Output), the bytes allowed, and the bytes needed when the codec knows them. |
| DictionaryRequired(id) | The stream needs a dictionary that was not given. |
| DictionaryMismatch | The stream needs a different dictionary from the one given. |
| Unsupported | The stream is valid but uses a feature the codec does not implement. |
Install
Download zipError kinds and limits shared by the streaming codecs of gaato/codecs.mbt.