Skip to content

Commit

Permalink
actually error on internal non-allowed error (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Oct 18, 2023
1 parent f1ea13e commit 48e3a08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tagbot/action/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ def handle_error(self, e: Exception) -> None:
"""
)
internal = False
allowed = False
if not allowed:
if internal:
logger.error("TagBot experienced an unexpected internal failure")
Expand All @@ -639,6 +640,8 @@ def handle_error(self, e: Exception) -> None:
except Exception:
logger.error("Issue reporting failed")
logger.info(traceback.format_exc())
finally:
raise Abort("Cannot continue due to internal failure")

def commit_sha_of_version(self, version: str) -> Optional[str]:
"""Get the commit SHA from a registered version."""
Expand Down
14 changes: 12 additions & 2 deletions test/action/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,19 @@ def test_handle_error(logger, format_exc):
r._report_error.assert_not_called()
r.handle_error(GithubException(502, "oops"))
r._report_error.assert_not_called()
r.handle_error(GithubException(404, "???"))
try:
r.handle_error(GithubException(404, "???"))
except Abort:
assert True
else:
assert False
r._report_error.assert_called_with("ahh")
r.handle_error(RuntimeError("?"))
try:
r.handle_error(RuntimeError("?"))
except Abort:
assert True
else:
assert False
r._report_error.assert_called_with("ahh")
logger.error.assert_called_with("Issue reporting failed")

Expand Down

0 comments on commit 48e3a08

Please sign in to comment.