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
|
|
@ -9,7 +9,10 @@ pub struct Ping {
|
|||
}
|
||||
|
||||
pub fn parse_ping(root: &Element) -> Result<Ping, Error> {
|
||||
assert!(root.is("ping", PING_NS));
|
||||
if !root.is("ping", PING_NS) {
|
||||
return Err(Error::ParseError("This is not a ping element.")),
|
||||
}
|
||||
|
||||
for _ in root.children() {
|
||||
return Err(Error::ParseError("Unknown child in ping element."));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue