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
|
|
@ -52,7 +52,10 @@ pub struct DataForm {
|
|||
}
|
||||
|
||||
pub fn parse_data_form(root: &Element) -> Result<DataForm, Error> {
|
||||
assert!(root.is("x", DATA_FORMS_NS));
|
||||
if !root.is("x", DATA_FORMS_NS) {
|
||||
return Err(Error::ParseError("This is not a data form element.")),
|
||||
}
|
||||
|
||||
let type_: DataFormType = match root.attr("type") {
|
||||
Some(type_) => type_.parse()?,
|
||||
None => return Err(Error::ParseError("Type attribute on data form is mandatory.")),
|
||||
|
|
|
|||
Loading…
Reference in a new issue