Coverage for src/qdrant_loader/core/chunking/docling/exceptions.py: 62%

8 statements  

« prev     ^ index     » next       coverage.py v7.15.0, created at 2026-07-20 10:15 +0000

1"""Errors the chunking layer raises — loud by design. 

2 

3The legacy markdown chunker degrades *silently*: a shape mismatch falls through to 

4a fallback splitter or returns one giant chunk with no signal. 

5This layer rejects that — when an invariant the contract depends on breaks, it 

6raises. These are the cases the chunker refuses to paper over. 

7""" 

8 

9from __future__ import annotations 

10 

11 

12class ChunkingError(Exception): 

13 """Base class for chunking errors raised by this package.""" 

14 

15 

16class EmptyDocumentError(ChunkingError): 

17 """The source produced no chunkable content — never emit a fake empty chunk.""" 

18 

19 

20class TokenizerUnavailableError(ChunkingError): 

21 """The configured tokenizer kind cannot be constructed for chunk sizing.""" 

22 

23 def __init__(self, kind: str, reason: str) -> None: 

24 super().__init__(f"cannot build {kind!r} tokenizer: {reason}") 

25 self.kind = kind 

26 self.reason = reason