Skip to content

Commit

Permalink
chore: raise from e instead of putting e in exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Sep 15, 2024
1 parent 29acd02 commit 75ae73c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ocdsindex/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def extract_sphinx(url, tree):
section_title = section.xpath("h1|h2|h3|h4|h5|h6")[0].text_content().rstrip("¶")
except IndexError as e:
logger.exception("No heading found\n%s", lxml.html.tostring(section).decode())
raise MissingHeadingError(e) from None
raise MissingHeadingError from e

if title != section_title:
title = f"{title} - {section_title}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_extract_sphinx_error(caplog):
parse("failure", "index.html"),
)

assert str(excinfo.value) == "list index out of range"
assert str(excinfo.value) == ""
assert len(caplog.records) == 1
assert caplog.records[0].levelname == "ERROR"
assert caplog.records[0].message == 'No heading found\n<section id="error">\n No heading.\n </section>\n'

0 comments on commit 75ae73c

Please sign in to comment.