use std::io;
use super::xpath_analyze::NotStreamableReason;
pub use crate::error::ErrorLocation;
#[derive(Debug, thiserror::Error)]
pub enum TransformError {
#[error("invalid xpath: {0}")]
InvalidXPath(String),
#[error("xml parse error: {0}")]
XmlParse(String),
#[error("xml parse error: {message} ({location})")]
XmlParseWithLocation {
message: String,
location: ErrorLocation,
},
#[error("io error: {0}")]
Io(#[from] io::Error),
#[error("utf8 error: {0}")]
Utf8(#[from] std::str::Utf8Error),
#[error("serialization error: {0}")]
Serialization(String),
#[error("modification error: {0}")]
Modification(String),
#[error(
"xpath '{xpath}' is not streamable: {reason}. Use .allow_fallback() to enable two-pass processing, or use a streamable XPath pattern."
)]
NotStreamable {
xpath: String,
reason: NotStreamableReason,
},
#[error(transparent)]
Other(#[from] crate::error::Error),
}
impl From<quick_xml::Error> for TransformError {
fn from(err: quick_xml::Error) -> Self {
TransformError::XmlParse(err.to_string())
}
}
pub type TransformResult<T> = std::result::Result<T, TransformError>;