decoder: better error message when failing to look up an id
This commit is contained in:
parent
1ac90bb74b
commit
278b3beafe
@ -82,17 +82,17 @@ pub fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
|
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
|
||||||
return maybe_find_item(item_id, items).get();
|
match maybe_find_item(item_id, items) {
|
||||||
|
None => fail!("lookup_item: id not found: %d", item_id),
|
||||||
|
Some(d) => d
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Looks up an item in the given metadata and returns an ebml doc pointing
|
// Looks up an item in the given metadata and returns an ebml doc pointing
|
||||||
// to the item data.
|
// to the item data.
|
||||||
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
|
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
|
||||||
let items = reader::get_doc(reader::Doc(data), tag_items);
|
let items = reader::get_doc(reader::Doc(data), tag_items);
|
||||||
match maybe_find_item(item_id, items) {
|
find_item(item_id, items)
|
||||||
None => fail!("lookup_item: id not found: %d", item_id),
|
|
||||||
Some(d) => d
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq)]
|
||||||
|
Loading…
Reference in New Issue
Block a user