1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::io::Error as IOError;

use strong_xml::XmlError;
use zip::result::ZipError;

/// Error type of docx-rs
#[derive(Debug)]
pub enum DocxError {
    IO(IOError),
    Xml(XmlError),
    Zip(ZipError),
}

impl From<IOError> for DocxError {
    fn from(err: IOError) -> Self {
        DocxError::IO(err)
    }
}

impl From<XmlError> for DocxError {
    fn from(err: XmlError) -> Self {
        DocxError::Xml(err)
    }
}

impl From<ZipError> for DocxError {
    fn from(err: ZipError) -> Self {
        DocxError::Zip(err)
    }
}

/// Specialized `Result` which the error value is `DocxError`.
pub type DocxResult<T> = Result<T, DocxError>;