Make enum decoding errors more informative.
By printing the actual value, as long as the expected range. I found this helpful when I encountered one of these errors.
This commit is contained in:
parent
9167eea553
commit
3449304722
1 changed files with 2 additions and 2 deletions
|
@ -59,14 +59,14 @@ fn decodable_body(
|
|||
})
|
||||
.collect();
|
||||
let message = format!(
|
||||
"invalid enum variant tag while decoding `{}`, expected 0..{}",
|
||||
"invalid enum variant tag while decoding `{}`, expected 0..{}, actual {{}}",
|
||||
ty_name,
|
||||
variants.len()
|
||||
);
|
||||
quote! {
|
||||
match ::rustc_serialize::Decoder::read_usize(__decoder) {
|
||||
#match_inner
|
||||
_ => panic!(#message),
|
||||
n => panic!(#message, n),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue