mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-04 02:21:47 +00:00
fix: replace silent exception swallowing with debug logging across tools
Add logger.debug() calls to 27 bare 'except: pass' blocks across 7 core files, giving visibility into errors that were previously silently swallowed. This makes it much easier to diagnose user-reported issues from debug logs. Files changed: - tools/terminal_tool.py: 5 catches (stat, termios, fd close, cleanup) - tools/delegate_tool.py: 7 catches + added logger (spinner, callbacks) - tools/browser_tool.py: 5 catches (screenshot/recording cleanup, daemon kill) - tools/code_execution_tool.py: 2 remaining catches (socket, server close) - gateway/session.py: 2 catches (platform enum parse, temp file cleanup) - agent/display.py: 2 catches + added logger (JSON parse in failure detect) - agent/prompt_builder.py: 1 catch (skill description read) Deliberately kept bare pass for: - ImportError checks for optional dependencies (terminal_tool.py) - SystemExit/KeyboardInterrupt handlers - Spinner _write catch (would spam on every frame when stdout closed) - process_registry PID-alive check (canonical os.kill(pid,0) pattern) Extends the pattern from PR #686 (@aydnOktay).
This commit is contained in:
parent
60cba55d82
commit
0fdeffe6c4
7 changed files with 49 additions and 45 deletions
|
|
@ -1615,10 +1615,10 @@ def _cleanup_old_screenshots(screenshots_dir, max_age_hours=24):
|
|||
try:
|
||||
if f.stat().st_mtime < cutoff:
|
||||
f.unlink()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass # Non-critical — don't fail the screenshot operation
|
||||
except Exception as e:
|
||||
logger.debug("Failed to clean old screenshot %s: %s", f, e)
|
||||
except Exception as e:
|
||||
logger.debug("Screenshot cleanup error (non-critical): %s", e)
|
||||
|
||||
|
||||
def _cleanup_old_recordings(max_age_hours=72):
|
||||
|
|
@ -1634,10 +1634,10 @@ def _cleanup_old_recordings(max_age_hours=72):
|
|||
try:
|
||||
if f.stat().st_mtime < cutoff:
|
||||
f.unlink()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.debug("Failed to clean old recording %s: %s", f, e)
|
||||
except Exception as e:
|
||||
logger.debug("Recording cleanup error (non-critical): %s", e)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
|
|
@ -1749,7 +1749,7 @@ def cleanup_browser(task_id: Optional[str] = None) -> None:
|
|||
os.kill(daemon_pid, signal.SIGTERM)
|
||||
logger.debug("Killed daemon pid %s for %s", daemon_pid, session_name)
|
||||
except (ProcessLookupError, ValueError, PermissionError, OSError):
|
||||
pass
|
||||
logger.debug("Could not kill daemon pid for %s (already dead or inaccessible)", session_name)
|
||||
shutil.rmtree(socket_dir, ignore_errors=True)
|
||||
|
||||
logger.debug("Removed task %s from active sessions", task_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue