Replace assert!()s with proper errors in parsers.
This commit is contained in:
parent
6a0724d133
commit
fc7a0517d3
8 changed files with 23 additions and 8 deletions
|
|
@ -18,7 +18,10 @@ pub struct MediaElement {
|
|||
}
|
||||
|
||||
pub fn parse_media_element(root: &Element) -> Result<MediaElement, Error> {
|
||||
assert!(root.is("media", MEDIA_ELEMENT_NS));
|
||||
if !root.is("media", MEDIA_ELEMENT_NS) {
|
||||
return Err(Error::ParseError("This is not a media element.")),
|
||||
}
|
||||
|
||||
let width = root.attr("width").and_then(|width| width.parse().ok());
|
||||
let height = root.attr("height").and_then(|height| height.parse().ok());
|
||||
let mut uris = vec!();
|
||||
|
|
|
|||
Loading…
Reference in a new issue