From b1aaae6b70e72b0838b1720517eb164b5d048c22 Mon Sep 17 00:00:00 2001 From: Robin Whittleton Date: Sun, 21 Jan 2024 20:07:46 +0100 Subject: [PATCH] Show the problematic heading on roman error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously it just gave a file reference, which doesn’t help much in poetry compilations for example. --- se/se_epub_generate_toc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/se/se_epub_generate_toc.py b/se/se_epub_generate_toc.py index 58007fc4..f25eedaa 100644 --- a/se/se_epub_generate_toc.py +++ b/se/se_epub_generate_toc.py @@ -564,7 +564,7 @@ def process_a_heading(node: EasyXmlElement, textf: str, is_toplevel: bool, singl try: roman.fromRoman(toc_item.roman) except roman.InvalidRomanNumeralError as err: - raise se.InvalidInputException(f"Heading tagged as roman numeral is invalid: [path][link=file://{textf}]{textf}[/][/].") from err + raise se.InvalidInputException(f"Heading tagged as roman numeral is invalid: {toc_item.roman} in [path][link=file://{textf}]{textf}[/][/].") from err toc_item.title = f"{toc_item.roman}" return toc_item if "ordinal" in epub_type: # but not a roman numeral (eg in Nietzche's Beyond Good and Evil) @@ -639,7 +639,7 @@ def evaluate_descendants(node: EasyXmlElement, toc_item: TocItem, textf: str) -> try: roman.fromRoman(toc_item.roman) except roman.InvalidRomanNumeralError as err: - raise se.InvalidInputException(f"Heading tagged as roman numeral is invalid: [path][link=file://{textf}]{textf}[/][/].") from err + raise se.InvalidInputException(f"Heading tagged as roman numeral is invalid: {toc_item.roman} in [path][link=file://{textf}]{textf}[/][/].") from err if not toc_item.title: toc_item.title = f"{toc_item.roman}" elif "ordinal" in epub_type: # but not a roman numeral or a labelled item, cases caught caught above