Skip to content

Commit

Permalink
fix: catch exceptions in shell tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Sep 28, 2024
1 parent 46340ca commit f42be8f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gptme/tools/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ def execute_shell(
print()

if not ask or confirm:
returncode, stdout, stderr = shell.run(cmd)
try:
returncode, stdout, stderr = shell.run(cmd)
except Exception as e:
yield Message("system", f"Error: {e}")
return
stdout = _shorten_stdout(stdout.strip(), pre_tokens=2000, post_tokens=8000)
stderr = _shorten_stdout(stderr.strip(), pre_tokens=2000, post_tokens=2000)

Expand Down

0 comments on commit f42be8f

Please sign in to comment.