aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/error.rs2
-rw-r--r--src/reader.rs48
-rw-r--r--src/xml/parsers_complete.rs7
3 files changed, 43 insertions, 14 deletions
diff --git a/src/error.rs b/src/error.rs
index ae4aa26..717dfdd 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -51,7 +51,7 @@ pub enum Error {
#[error("utf8 conversion: {0}")]
Utf8Error(#[from] Utf8Error),
#[error("nom parsing: {0}")]
- ParseError(String),
+ ParseError(String, String),
#[error("unknown xml entity reference `&{0};`")]
EntityProcessError(String),
#[error("invalid character reference: {0}")]
diff --git a/src/reader.rs b/src/reader.rs
index 93b28af..c4d85f7 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -107,8 +107,12 @@ where
self.read_buf().await?;
}
// TODO: better error
- Err::Error(e) => return Err(Error::ParseError(e.to_string())),
- Err::Failure(e) => return Err(Error::ParseError(e.to_string())),
+ Err::Error(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
+ Err::Failure(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
},
}
}
@@ -150,8 +154,12 @@ where
self.read_buf().await?;
}
// TODO: better error
- Err::Error(e) => return Err(Error::ParseError(e.to_string())),
- Err::Failure(e) => return Err(Error::ParseError(e.to_string())),
+ Err::Error(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
+ Err::Failure(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
},
}
}
@@ -184,8 +192,12 @@ where
self.read_buf().await?;
}
// TODO: better error
- Err::Error(e) => return Err(Error::ParseError(e.to_string())),
- Err::Failure(e) => return Err(Error::ParseError(e.to_string())),
+ Err::Error(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
+ Err::Failure(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
},
}
}
@@ -215,8 +227,12 @@ where
self.read_buf().await?;
}
// TODO: better error
- Err::Error(e) => return Err(Error::ParseError(e.to_string())),
- Err::Failure(e) => return Err(Error::ParseError(e.to_string())),
+ Err::Error(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
+ Err::Failure(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
},
}
}
@@ -300,8 +316,12 @@ where
self.read_buf().await?;
}
// TODO: better error
- Err::Error(e) => return Err(Error::ParseError(e.to_string())),
- Err::Failure(e) => return Err(Error::ParseError(e.to_string())),
+ Err::Error(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
+ Err::Failure(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
},
},
},
@@ -361,8 +381,12 @@ where
self.read_buf().await?;
}
// TODO: better error
- Err::Error(e) => return Err(Error::ParseError(e.to_string())),
- Err::Failure(e) => return Err(Error::ParseError(e.to_string())),
+ Err::Error(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
+ Err::Failure(e) => {
+ return Err(Error::ParseError(input.to_string(), e.to_string()))
+ }
},
}
}
diff --git a/src/xml/parsers_complete.rs b/src/xml/parsers_complete.rs
index f18d0ff..1e2ac31 100644
--- a/src/xml/parsers_complete.rs
+++ b/src/xml/parsers_complete.rs
@@ -40,7 +40,12 @@ pub trait Parser<'s> {
return Err(crate::error::Error::ExtraData(rest.to_string()));
}
}
- Result::Err(e) => return Err(crate::error::Error::ParseError(e.to_string())),
+ Result::Err(e) => {
+ return Err(crate::error::Error::ParseError(
+ input.to_string(),
+ e.to_string(),
+ ))
+ }
}
}
}