Skip to content

refactor: narrow broad exception catches in cache.py #114

Description

@jessica-claude

Problem

cache.py has 7 bare except Exception blocks (lines 35, 49, 67, 81, 89, 96, 103) that catch and log all errors. This masks specific failure modes — disk full, permission denied, corrupt cache file — behind generic log messages.

Why it matters

When the cache fails, the error is logged but calling code continues with potentially stale or missing data. Users can't distinguish "cache unavailable" from "cache corrupted" without reading debug logs.

Suggested approach

Narrow to specific exception types (OSError, KeyError, diskcache-specific exceptions) and let unexpected errors propagate. The cache is designed fail-open, so broad catches aren't fundamentally wrong — but they should be scoped to expected failures.

Found by

Codebase audit (2026-04-27)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions