Skip to content

Commit

Permalink
🔊 Improves exception logging
Browse files Browse the repository at this point in the history
Makes sure stacktrace is being properly displayed on exception
  • Loading branch information
AndreMiras committed Nov 29, 2020
1 parent 3c62ca4 commit bb2d6b0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]
- Fixes entrypoint assertion error ([dfm](https://github.com/dfm)), refs #5
- Fixes parallel mode ([johanneswilm](https://github.com/johanneswilm)), refs #8
- Improves exception logging

## [v20200413]
- Made `github-token` parameter optional
Expand Down
7 changes: 4 additions & 3 deletions src/entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class ExitCode(Enum):


def set_failed(message):
log.error(message)
exc_info = message if isinstance(message, Exception) else None
log.error(message, exc_info=exc_info)
sys.exit(ExitCode.FAILURE)


Expand Down Expand Up @@ -57,9 +58,9 @@ def run_coveralls(repo_token, parallel=False, flag_name=False, base_path=False):
break
except CoverallsException as e:
log.warning(
f"Failed submitting coverage with service_name: {service_name}"
f"Failed submitting coverage with service_name: {service_name}",
exc_info=e,
)
log.warning(e)
if result is None:
set_failed("Failed to submit coverage")
log.debug(result)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ def test_run_coveralls_wear_error_once(self):
"Patching os.environ with: "
"{'COVERALLS_REPO_TOKEN': 'TOKEN', 'COVERALLS_PARALLEL': ''}"
),
mock.call.warning("Failed submitting coverage with service_name: github"),
mock.call.warning(side_effect[0]),
mock.call.warning(
"Failed submitting coverage with service_name: github",
exc_info=side_effect[0],
),
mock.call.info(
"Trying submitting coverage with service_name: github-actions..."
),
Expand Down

0 comments on commit bb2d6b0

Please sign in to comment.