Skip to content

Commit f762343

Browse files
committed
Escalate PDFCombineError
1 parent 7758bfb commit f762343

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/pdfbaker/document.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
from jinja2 import Template
1010

1111
from .common import combine_pdfs, compress_pdf, convert_svg_to_pdf, deep_merge
12-
from .errors import PDFBakeError, PDFCompressionError, SVGConversionError
12+
from .errors import (
13+
PDFBakeError,
14+
PDFCombineError,
15+
PDFCompressionError,
16+
SVGConversionError,
17+
)
1318
from .render import create_env, prepare_template_context
1419

1520
__all__ = [
@@ -204,10 +209,13 @@ def _process_with_custom_bake(self, bake_path: Path) -> None:
204209

205210
def _finalize(self, pdf_files: list[Path], config: dict[str, Any]) -> None:
206211
"""Combine pages and handle compression."""
207-
combined_pdf = combine_pdfs(
208-
pdf_files,
209-
self.build_dir / f"{config['filename']}.pdf",
210-
)
212+
try:
213+
combined_pdf = combine_pdfs(
214+
pdf_files,
215+
self.build_dir / f"{config['filename']}.pdf",
216+
)
217+
except PDFCombineError as exc:
218+
raise PDFBakeError(f"Failed to combine PDFs: {exc}") from exc
211219

212220
output_path = self.dist_dir / f"{config['filename']}.pdf"
213221

0 commit comments

Comments
 (0)