Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/MuhammadSalmanAhmad/rag-pdf-highlighter/llms.txt

Use this file to discover all available pages before exploring further.

RAG PDF Highlighter raises plain Python exceptions — all subclasses of HighlightError — so you can catch them without importing FastAPI. The exception hierarchy is defined in rag_pdf_highlighter.exceptions.
Exception
└── HighlightError
    ├── PDFDownloadError
    ├── PDFNotFoundError
    └── NoDocumentsError

Exception reference

Base exception for all highlighting errors. Catch this to handle any error from the library.
from rag_pdf_highlighter.exceptions import HighlightError
Raised when download_pdf() cannot fetch the PDF from the given URL. Causes include network errors, HTTP 4xx/5xx responses, and timeouts.
from rag_pdf_highlighter.exceptions import PDFDownloadError
Raised when highlight_chunks_in_pdf() is called with a pdf_path that does not exist on disk.
from rag_pdf_highlighter.exceptions import PDFNotFoundError
Raised when highlight_chunks_in_pdf() receives an empty documents list.
from rag_pdf_highlighter.exceptions import NoDocumentsError

Catching exceptions

The example below shows how to handle each exception type in order of specificity, with HighlightError as the final catch-all for any other library error.
from rag_pdf_highlighter.exceptions import (
    HighlightError,
    PDFDownloadError,
    PDFNotFoundError,
    NoDocumentsError,
)
from rag_pdf_highlighter.utils.pdf_helpers import highlight_chunks_in_pdf

try:
    output = highlight_chunks_in_pdf(pdf_path="./report.pdf", documents=docs)
except NoDocumentsError:
    print("Provide at least one document to highlight")
except PDFNotFoundError as e:
    print(f"PDF file not found: {e}")
except PDFDownloadError as e:
    print(f"Could not download PDF: {e}")
except HighlightError as e:
    print(f"Highlighting failed: {e}")
PDFDownloadError is only raised by download_pdf(), not by highlight_chunks_in_pdf() — you will see it when using the async download helper.

Build docs developers (and LLMs) love