Skip to main content

anytomd/
error.rs

1/// Errors that can occur during document conversion.
2#[derive(Debug, thiserror::Error)]
3pub enum ConvertError {
4    #[error("unsupported format: {extension}")]
5    UnsupportedFormat { extension: String },
6
7    #[error("input too large: {size} bytes exceeds limit of {limit} bytes")]
8    InputTooLarge { size: usize, limit: usize },
9
10    #[error("failed to read ZIP archive")]
11    ZipError(#[from] zip::result::ZipError),
12
13    #[error("failed to parse XML")]
14    XmlError(#[from] quick_xml::Error),
15
16    #[error("failed to read spreadsheet")]
17    SpreadsheetError(#[from] calamine::Error),
18
19    #[error("I/O error")]
20    Io(#[from] std::io::Error),
21
22    #[error("invalid UTF-8 content")]
23    Utf8Error(#[from] std::string::FromUtf8Error),
24
25    #[error("malformed document: {reason}")]
26    MalformedDocument { reason: String },
27
28    #[error("image description failed: {reason}")]
29    ImageDescriptionError { reason: String },
30}