diff --git a/src/hermes/commands/harvest/git.py b/src/hermes/commands/harvest/git.py index 2b9182e7..c31f5a31 100644 --- a/src/hermes/commands/harvest/git.py +++ b/src/hermes/commands/harvest/git.py @@ -15,6 +15,7 @@ import shutil from hermes.model.context import HermesHarvestContext +from hermes.model.errors import HermesValidationError _log = logging.getLogger('harvest.git') @@ -274,15 +275,16 @@ def harvest_git(click_ctx: click.Context, ctx: HermesHarvestContext): p = subprocess.run([git_exe, "rev-parse", "--abbrev-ref", "HEAD"], capture_output=True) if p.returncode: - raise RuntimeError(f"`git branch` command failed with code {p.returncode}: " - f"'{p.stderr.decode(SHELL_ENCODING)}'!") + raise HermesValidationError(f"`git branch` command failed with code {p.returncode}: " + f"'{p.stderr.decode(SHELL_ENCODING).rstrip()}'!") + git_branch = p.stdout.decode(SHELL_ENCODING).strip() # TODO: should we warn or error if the HEAD is detached? p = subprocess.run([git_exe, "log", f"--pretty={_GIT_SEP.join(_GIT_FORMAT)}"] + _GIT_ARGS, capture_output=True) if p.returncode: - raise RuntimeError(f"`git log` command failed with code {p.returncode}: " - f"'{p.stderr.decode(SHELL_ENCODING)}'!") + raise HermesValidationError(f"`git log` command failed with code {p.returncode}: " + f"'{p.stderr.decode(SHELL_ENCODING).rstrip()}'!") log = p.stdout.decode(SHELL_ENCODING).split('\n') for line in log: diff --git a/src/hermes/model/context.py b/src/hermes/model/context.py index 86a9469a..e10dbd9f 100644 --- a/src/hermes/model/context.py +++ b/src/hermes/model/context.py @@ -173,6 +173,9 @@ def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is not None and issubclass(exc_type, HermesValidationError): exc = traceback.TracebackException(exc_type, exc_val, exc_tb) self._base.error(self._ep, exc) + self._log.warning("%s: %s", + exc_type, + ' '.join(map(str, exc_val.args))) return True def update(self, _key: str, _value: t.Any, **kwargs: t.Any):