1use thiserror::Error;
2
3#[derive(Error, Debug, Clone)]
5pub enum HOCRParserError {
6 #[error("Unknown element found in hOCR file at {0}: elements either must be defined in the spec or start with 'ocrx_' prefix")]
8 UnknownElement(roxmltree::TextPos),
9 #[error("Unknown property found in hOCR file at {0}: properties either must be defined in the spec or start with 'x_' prefix")]
11 UnknownProperty(roxmltree::TextPos),
12 #[error("Cannot construct hOCR Element from node: it is not of type Element at {0}")]
14 NodeIsNotElement(roxmltree::TextPos),
15 #[error("No <head> element found in hOCR file")]
17 NoHeadElement,
18 #[error("No <body> element found in hOCR file")]
20 NoBodyElement,
21 #[error("No OCR system found in hOCR file metadata; invalid hOCR according to spec")]
23 NoOCRSystem,
24 #[error("No OCR capabilities found in hOCR file metadata; invalid hOCR according to spec")]
26 NoOCRCapabilities,
27 #[error("roxmltree error: {0}")]
29 XMLParseError(#[from] roxmltree::Error),
30}
31
32pub type Result<T, E = HOCRParserError> = std::result::Result<T, E>;