Skip to content

Commit bc16f8c

Browse files
committed
fix for #37: print more informative error message when page number can't be converted to an int
1 parent 823667c commit bc16f8c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pdftocio/tocparser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def parse_entry(entry: List, nLine: int) -> ToCEntry:
2323
*entry[indent + 2:] # vpos
2424
)
2525
return toc_entry
26+
except ValueError as e:
27+
print(f"Unable to parse toc entry {entry} from line {nLine};",
28+
f"Couldn't convert '{entry[indent + 1]}' to a page number.",
29+
file=sys.stderr)
30+
raise e
2631
except IndexError as e:
2732
print(f"Unable to parse toc entry {entry} from line {nLine};",
2833
f"Need at least {indent + 2} parts but only have {len(entry)}.",

0 commit comments

Comments
 (0)