Skip to content

Commit

Permalink
Show the problematic heading on roman error
Browse files Browse the repository at this point in the history
Previously it just gave a file reference, which doesn’t help much in poetry compilations for example.
  • Loading branch information
robinwhittleton authored and acabal committed Jan 21, 2024
1 parent 2c43cc3 commit 7e28efe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions se/se_epub_generate_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<span epub:type=\"z3998:roman\">{toc_item.roman}</span>"
return toc_item
if "ordinal" in epub_type: # but not a roman numeral (eg in Nietzche's Beyond Good and Evil)
Expand Down Expand Up @@ -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"<span epub:type=\"z3998:roman\">{toc_item.roman}</span>"
elif "ordinal" in epub_type: # but not a roman numeral or a labelled item, cases caught caught above
Expand Down

0 comments on commit 7e28efe

Please sign in to comment.