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",
)
}Install
Download zipError kinds and limits shared by the streaming codecs of gaato/codecs.mbt.