layoutparser_ort/
error.rs

1use thiserror::Error;
2
3#[derive(Error, Debug)]
4/// layoutparser-ort error variants
5pub enum Error {
6    #[error("ort (onnxruntime) error: {0}")]
7    /// [`ort`] (onnxruntime) error
8    Ort(#[from] ort::Error),
9    #[error("hf-hub error: {0}")]
10    /// Hugging Face API error
11    HuggingFace(#[from] hf_hub::api::sync::ApiError),
12    #[error("tesseract error: {0}")]
13    #[cfg(feature = "ocr")]
14    /// Tesseract error
15    TesseractError(#[from] tesseract::TesseractError),
16    #[error("hocr-parser error: {0}")]
17    #[cfg(feature = "ocr")]
18    /// hOCR parsing error
19    HOCRParserError(#[from] hocr_parser::HOCRParserError),
20    #[error("hOCR element conversion error: {0}")]
21    #[cfg(feature = "ocr")]
22    /// hOCR element conversion error
23    HOCRElementConversionError(#[from] crate::ocr::HOCRElementConversionError),
24}
25
26/// A `Result` type alias using [`enum@Error`] instances as the error variant.
27pub type Result<T, E = Error> = std::result::Result<T, E>;