Skip to main content

model_error

Function model_error 

Source
pub fn model_error<'a>(e: &'a (dyn Error + 'static)) -> Option<&'a ModelError>
Expand description

Find the ModelError in an error chain, if there is one.

pdf-engine surfaces these as EngineError::Io: match that variant and walk the inner std::io::Error with this helper, then branch on ModelErrorKind::code. The walk must start at the io::Error, not above it: EngineError::Io is thiserror::transparent, which forwards source() to the inner error’s own source() – and that is None for an [std::io::Error::other] payload, which is exactly how this error travels. So every io::Error on the way is also opened through get_ref(), the same way EngineError::ocr_message reads its OCR causes.