fix: replace 59 bare except clauses with proper logging (#25)

All `except Exception:` now catch as `except Exception as exc:` with
appropriate logging (warning for critical paths, debug for graceful degradation).

Added logger setup to 4 files that lacked it:
- src/timmy/memory/vector_store.py
- src/dashboard/middleware/csrf.py
- src/dashboard/middleware/security_headers.py
- src/spark/memory.py

31 files changed across timmy core, dashboard, infrastructure, integrations.
Zero bare excepts remain. 1340 tests passing.
This commit is contained in:
2026-03-14 19:07:14 -04:00
parent b01c1cb582
commit fdc5b861ca
31 changed files with 131 additions and 70 deletions

View File

@@ -89,7 +89,8 @@ def _get_ollama_model() -> str:
name = model.get("name", "")
if name == configured or name == f"{configured}:latest":
return configured
except Exception:
except Exception as exc:
logger.debug("Model validation failed: %s", exc)
pass
# Fallback to configured model
@@ -186,7 +187,8 @@ def get_memory_status() -> dict[str, Any]:
tier3_info["available"] = True
tier3_info["vector_count"] = count[0] if count else 0
conn.close()
except Exception:
except Exception as exc:
logger.debug("Memory status query failed: %s", exc)
pass
# Self-coding journal stats
@@ -212,7 +214,8 @@ def get_memory_status() -> dict[str, Any]:
"success_rate": round(counts.get("success", 0) / total, 2) if total else 0,
}
conn.close()
except Exception:
except Exception as exc:
logger.debug("Journal stats query failed: %s", exc)
pass
return {
@@ -303,7 +306,8 @@ def get_live_system_status() -> dict[str, Any]:
uptime = (datetime.now(UTC) - _START_TIME).total_seconds()
result["uptime_seconds"] = int(uptime)
except Exception:
except Exception as exc:
logger.debug("Uptime calculation failed: %s", exc)
result["uptime_seconds"] = None
# Discord status
@@ -311,7 +315,8 @@ def get_live_system_status() -> dict[str, Any]:
from integrations.chat_bridge.vendors.discord import discord_bot
result["discord"] = {"state": discord_bot.state.name}
except Exception:
except Exception as exc:
logger.debug("Discord status check failed: %s", exc)
result["discord"] = {"state": "unknown"}
result["timestamp"] = datetime.now(UTC).isoformat()