Skip to main content

Exception Hierarchy

All OCR exceptions inherit from OCRError, allowing you to catch all OCR errors at once or handle specific exceptions individually.

Base: OCRError

Parent of all OCR exceptions. Carries 3 attributes: str() output format: [ERROR_CODE] message (Original: original error)

OCRProviderError

Raised during engine initialization and dependency errors.

OCRFileNotFoundError

Raised when the file does not exist or the path is not a file. Thrown by Layer 0 (document_converter).

OCRUnsupportedFormatError

Raised when an unsupported file format is provided. Thrown by Layer 0. Supported formats: .png, .jpg, .jpeg, .bmp, .tiff, .tif, .gif, .webp, .pdf

OCRProcessingError

Raised when an error occurs at the engine level during OCR processing. Each engine uses its own error code.

OCRTimeoutError

Raised when layer_1_timeout is exceeded in the OCR orchestrator. Applied per page — if page 3 of a 5-page PDF times out, only that page raises the error.

Import

Catch Pattern

Handle exceptions from most specific to most general: