1
Fork 0

Remove die!, raplace invocations with fail! Issue #4524 pt 3

This commit is contained in:
Nick Desaulniers 2013-02-11 19:26:38 -08:00 committed by Brian Anderson
parent c51ecc3223
commit 4445b38df2
363 changed files with 910 additions and 906 deletions

View file

@ -257,7 +257,7 @@ pub impl PrettyEncoder: serialize::Encoder {
fn emit_managed(&self, f: fn()) { f() }
fn emit_enum(&self, name: &str, f: fn()) {
if name != "option" { die!(~"only supports option enum") }
if name != "option" { fail!(~"only supports option enum") }
f()
}
fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) {
@ -773,7 +773,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_nil");
match *self.pop() {
Null => (),
_ => die!(~"not a null")
_ => fail!(~"not a null")
}
}
@ -793,7 +793,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_bool");
match *self.pop() {
Boolean(b) => b,
_ => die!(~"not a boolean")
_ => fail!(~"not a boolean")
}
}
@ -803,13 +803,13 @@ pub impl Decoder: serialize::Decoder {
debug!("read_float");
match *self.pop() {
Number(f) => f,
_ => die!(~"not a number")
_ => fail!(~"not a number")
}
}
fn read_char(&self) -> char {
let v = str::chars(self.read_owned_str());
if v.len() != 1 { die!(~"string must have one character") }
if v.len() != 1 { fail!(~"string must have one character") }
v[0]
}
@ -817,7 +817,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_owned_str");
match *self.pop() {
String(ref s) => copy *s,
_ => die!(~"not a string")
_ => fail!(~"not a string")
}
}
@ -825,7 +825,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_managed_str");
match *self.pop() {
String(ref s) => s.to_managed(),
_ => die!(~"not a string")
_ => fail!(~"not a string")
}
}
@ -841,7 +841,7 @@ pub impl Decoder: serialize::Decoder {
fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T {
debug!("read_enum(%s)", name);
if name != ~"option" { die!(~"only supports the option enum") }
if name != ~"option" { fail!(~"only supports the option enum") }
f()
}
@ -856,7 +856,7 @@ pub impl Decoder: serialize::Decoder {
fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T {
debug!("read_enum_variant_arg(idx=%u)", idx);
if idx != 0 { die!(~"unknown index") }
if idx != 0 { fail!(~"unknown index") }
f()
}
@ -864,7 +864,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_owned_vec()");
let len = match *self.peek() {
List(ref list) => list.len(),
_ => die!(~"not a list"),
_ => fail!(~"not a list"),
};
let res = f(len);
self.pop();
@ -875,7 +875,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_owned_vec()");
let len = match *self.peek() {
List(ref list) => list.len(),
_ => die!(~"not a list"),
_ => fail!(~"not a list"),
};
let res = f(len);
self.pop();
@ -889,7 +889,7 @@ pub impl Decoder: serialize::Decoder {
self.stack.push(&list[idx]);
f()
}
_ => die!(~"not a list"),
_ => fail!(~"not a list"),
}
}
@ -913,20 +913,20 @@ pub impl Decoder: serialize::Decoder {
match *top {
Object(ref obj) => {
match obj.find(&name.to_owned()) {
None => die!(fmt!("no such field: %s", name)),
None => fail!(fmt!("no such field: %s", name)),
Some(json) => {
self.stack.push(json);
f()
}
}
}
Number(_) => die!(~"num"),
String(_) => die!(~"str"),
Boolean(_) => die!(~"bool"),
List(_) => die!(fmt!("list: %?", top)),
Null => die!(~"null"),
Number(_) => fail!(~"num"),
String(_) => fail!(~"str"),
Boolean(_) => fail!(~"bool"),
List(_) => fail!(fmt!("list: %?", top)),
Null => fail!(~"null"),
//_ => die!(fmt!("not an object: %?", *top))
//_ => fail!(fmt!("not an object: %?", *top))
}
}
@ -944,7 +944,7 @@ pub impl Decoder: serialize::Decoder {
self.stack.push(&list[idx]);
f()
}
_ => die!(~"not a list")
_ => fail!(~"not a list")
}
}
}