mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 08:37:14 +00:00
std: add some better failure msgs to json
This commit is contained in:
parent
83e831bc22
commit
c317d3f6fa
|
@ -827,7 +827,7 @@ fn read_owned_str(&self) -> ~str {
|
|||
debug!("read_owned_str");
|
||||
match *self.pop() {
|
||||
String(ref s) => copy *s,
|
||||
_ => fail!(~"not a string")
|
||||
ref json => fail!(fmt!("not a string: %?", *json))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -835,7 +835,7 @@ fn read_managed_str(&self) -> @str {
|
|||
debug!("read_managed_str");
|
||||
match *self.pop() {
|
||||
String(ref s) => s.to_managed(),
|
||||
_ => fail!(~"not a string")
|
||||
ref json => fail!(fmt!("not a string: %?", *json))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -872,7 +872,7 @@ fn read_enum_variant<T>(&self, names: &[&str], f: &fn(uint) -> T) -> T {
|
|||
let name = match *self.peek() {
|
||||
String(ref s) => s,
|
||||
List([String(ref s), .. _]) => s,
|
||||
json => fail!(fmt!("invalid variant: %?", json)),
|
||||
ref json => fail!(fmt!("invalid variant: %?", *json)),
|
||||
};
|
||||
let idx = match vec::position(names, |n| str::eq_slice(*n, *name)) {
|
||||
Some(idx) => idx,
|
||||
|
|
Loading…
Reference in a new issue