diff --git a/src/body.rs b/src/body.rs
index 0bf2f498dcae3490d8bc1723198c97a64dbbe11e..43bd6914852cfab737d2018e8215a49683158c1b 100644
--- a/src/body.rs
+++ b/src/body.rs
@@ -15,7 +15,7 @@ impl MessagePayload for Body {}
pub fn parse_body(root: &Element) -> Result
{
if !root.is("body", JABBER_CLIENT_NS) {
- return Err(Error::ParseError("Not a body element."));
+ return Err(Error::ParseError("This is not a body element."));
}
for _ in root.children() {
return Err(Error::ParseError("Unknown child in body element."));
diff --git a/src/chatstates.rs b/src/chatstates.rs
index 8941408dbdecdf19f46fea81172f660f5dfc4671..d84880c6591faddc50ff759ea634fccd4d730fd0 100644
--- a/src/chatstates.rs
+++ b/src/chatstates.rs
@@ -31,7 +31,7 @@ pub fn parse_chatstate(root: &Element) -> Result {
} else if root.is("paused", CHATSTATES_NS) {
Ok(ChatState::Paused)
} else {
- Err(Error::ParseError("Unknown chatstate element."))
+ Err(Error::ParseError("This is not a chatstate element."))
}
}
diff --git a/src/data_forms.rs b/src/data_forms.rs
index f4eb70c834487de4db9b088974e2b782db1d0aa5..68e0e00d43e9163bfb62394f7c67851e63ada81f 100644
--- a/src/data_forms.rs
+++ b/src/data_forms.rs
@@ -52,7 +52,10 @@ pub struct DataForm {
}
pub fn parse_data_form(root: &Element) -> Result {
- 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.")),
diff --git a/src/disco.rs b/src/disco.rs
index e436b2620e899bada9cb0b50a9123ba3e7da858c..d51636e2c09be6c75117ef15ee1739154411701a 100644
--- a/src/disco.rs
+++ b/src/disco.rs
@@ -29,7 +29,10 @@ pub struct Disco {
}
pub fn parse_disco(root: &Element) -> Result {
- assert!(root.is("query", DISCO_INFO_NS));
+ if !root.is("query", DISCO_INFO_NS) {
+ return Err(Error::ParseError("This is not a disco#info element.")),
+ }
+
let mut identities: Vec = vec!();
let mut features: Vec = vec!();
let mut extensions: Vec = vec!();
diff --git a/src/ibb.rs b/src/ibb.rs
index 1868772ee83e424b326780f5dd14fbb7dc44f9aa..64363c358164af5236816567d9b41d66c36fcde0 100644
--- a/src/ibb.rs
+++ b/src/ibb.rs
@@ -64,7 +64,7 @@ pub fn parse_ibb(root: &Element) -> Result {
stanza: stanza
})
} else {
- Err(Error::ParseError("Unknown ibb element."))
+ Err(Error::ParseError("This is not an ibb element."))
}
}
diff --git a/src/jingle.rs b/src/jingle.rs
index 37912a020c6a02edd9e54d14e85a5f4fdb722189..00b390e4409cf2574bd86863fd990409bf59474f 100644
--- a/src/jingle.rs
+++ b/src/jingle.rs
@@ -209,7 +209,10 @@ pub struct Jingle {
}
pub fn parse_jingle(root: &Element) -> Result {
- assert!(root.is("jingle", JINGLE_NS));
+ if !root.is("jingle", JINGLE_NS) {
+ return Err(Error::ParseError("This is not a Jingle element.")),
+ }
+
let mut contents: Vec = vec!();
let action = root.attr("action")
diff --git a/src/media_element.rs b/src/media_element.rs
index 86f286eebce54140104076fa18200e8e757521c4..d912f126f80200445d6f42135052b2b5a8cfb702 100644
--- a/src/media_element.rs
+++ b/src/media_element.rs
@@ -18,7 +18,10 @@ pub struct MediaElement {
}
pub fn parse_media_element(root: &Element) -> Result {
- 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!();
diff --git a/src/ping.rs b/src/ping.rs
index 7176fa42baffa14fdad058c7c94312f2db7f189b..39145e2253ee0f9255e733e656041e34b8a77271 100644
--- a/src/ping.rs
+++ b/src/ping.rs
@@ -9,7 +9,10 @@ pub struct Ping {
}
pub fn parse_ping(root: &Element) -> Result {
- 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."));
}