use thiserror::Error;
pub type Result<T> = std::result::Result<T, DocxError>;
#[derive(Debug, Error)]
pub enum DocxError {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("zip error: {0}")]
Zip(#[from] zip::result::ZipError),
#[error("xml error: {0}")]
Xml(#[from] quick_xml::Error),
#[error("parse error: {0}")]
Parse(String),
#[error("resource limit exceeded: {0}")]
ResourceLimit(String),
#[error("parity verification failed: {0}")]
Parity(String),
#[error("render cancelled")]
Cancelled,
}
impl DocxError {
pub(crate) fn parse(message: impl Into<String>) -> Self {
Self::Parse(message.into())
}
pub(crate) fn resource_limit(message: impl Into<String>) -> Self {
Self::ResourceLimit(message.into())
}
}
impl From<quick_xml::escape::EscapeError> for DocxError {
fn from(error: quick_xml::escape::EscapeError) -> Self {
Self::Parse(error.to_string())
}
}