refactor: enhance error handling with structured logging across multiple modules

- Updated various modules including cli.py, run_agent.py, gateway, and tools to replace silent exception handling with structured logging.
- Improved error messages to provide more context, aiding in debugging and monitoring.
- Ensured consistent logging practices throughout the codebase, enhancing traceability and maintainability.
This commit is contained in:
teknium1 2026-02-21 03:32:11 -08:00
parent cbff1b818c
commit 748fd3db88
14 changed files with 134 additions and 110 deletions

8
cli.py
View file

@ -823,8 +823,8 @@ class HermesCLI:
try:
from hermes_state import SessionDB
self._session_db = SessionDB()
except Exception:
pass # SQLite session store is optional
except Exception as e:
logger.debug("SQLite session store not available: %s", e)
try:
self.agent = AIAgent(
@ -2130,8 +2130,8 @@ class HermesCLI:
if hasattr(self, '_session_db') and self._session_db and self.agent:
try:
self._session_db.end_session(self.agent.session_id, "cli_close")
except Exception:
pass
except Exception as e:
logger.debug("Could not close session in DB: %s", e)
_run_cleanup()
print("\nGoodbye! ⚕")