diff --git a/src/body.rs b/src/body.rs
index 0bf2f49..43bd691 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 8941408..d84880c 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 f4eb70c..68e0e00 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 e436b26..d51636e 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 1868772..64363c3 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 37912a0..00b390e 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 86f286e..d912f12 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 7176fa4..39145e2 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."));
}