Skip to content

Commit c317d3f

Browse files
committed
std: add some better failure msgs to json
1 parent 83e831b commit c317d3f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libstd/json.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -827,15 +827,15 @@ impl<'self> serialize::Decoder for Decoder<'self> {
827827
debug!("read_owned_str");
828828
match *self.pop() {
829829
String(ref s) => copy *s,
830-
_ => fail!(~"not a string")
830+
ref json => fail!(fmt!("not a string: %?", *json))
831831
}
832832
}
833833
834834
fn read_managed_str(&self) -> @str {
835835
debug!("read_managed_str");
836836
match *self.pop() {
837837
String(ref s) => s.to_managed(),
838-
_ => fail!(~"not a string")
838+
ref json => fail!(fmt!("not a string: %?", *json))
839839
}
840840
}
841841
@@ -872,7 +872,7 @@ impl<'self> serialize::Decoder for Decoder<'self> {
872872
let name = match *self.peek() {
873873
String(ref s) => s,
874874
List([String(ref s), .. _]) => s,
875-
json => fail!(fmt!("invalid variant: %?", json)),
875+
ref json => fail!(fmt!("invalid variant: %?", *json)),
876876
};
877877
let idx = match vec::position(names, |n| str::eq_slice(*n, *name)) {
878878
Some(idx) => idx,

0 commit comments

Comments
 (0)