Skip to content

Commit

Permalink
fix: raise original error message alongside generic GitError message (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
sale3 authored Sep 24, 2024
1 parent 194d185 commit 7242224
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions taf/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List, Optional, Any, Tuple
import subprocess


class TAFError(Exception):
Expand Down Expand Up @@ -28,14 +29,14 @@ def __init__(
self,
repo: Any,
command: Optional[str] = None,
error: Optional[Exception] = None,
error: Optional[subprocess.CalledProcessError] = None,
message: Optional[str] = None,
):
if message is None:
if command is not None:
message = f"error occurred while executing {command}"
if error is not None:
message = f"{message}:\n{str(error)}"
message = f"{message}:\n{str(error.stdout)}"
elif error is not None:
message = str(error)
else:
Expand Down
2 changes: 1 addition & 1 deletion taf/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ def commit(self, message: str) -> str:
return self._git("rev-parse HEAD")
except subprocess.CalledProcessError as e:
raise GitError(
repo=self, message=f"could not commit changes due to:\n{e}"
repo=self, message=f"could not commit changes due to:\n{e}", error=e
)
else:
raise NothingToCommitError(repo=self, message="No changes to commit")
Expand Down

0 comments on commit 7242224

Please sign in to comment.