User Outcome
A user can query which exceptions are caught where, trace error handling patterns, and identify unhandled exception types in the codebase.
Background
Currently we don't track exception handling. Knowing what exceptions are caught (and where) is valuable for:
- Understanding error handling coverage
- Finding bare
except: clauses
- Identifying exception hierarchies
- Tracking custom exception usage
Proposal
Extract exception information from try/except blocks:
from myapp.exceptions import ValidationError
try:
validate(data)
except ValidationError as e:
log.error(e)
except (KeyError, ValueError):
pass
except: # bare except
pass
Create relationships:
:Function -[:CATCHES]-> :ExceptionType
- Track bare excepts as special case
Example Queries
// Functions that catch specific exception
MATCH (f:Function)-[:CATCHES]->(e {name: "ValidationError"})
// Functions with bare except (code smell)
MATCH (f:Function)-[:CATCHES]->(e {name: "*"})
// Most commonly caught exceptions
MATCH (f:Function)-[:CATCHES]->(e)
RETURN e.name, count(f) as catch_count
ORDER BY catch_count DESC
Benefits
- Identify missing error handling
- Find overly broad exception catches
- Track custom exception usage
- Code quality rule: "no bare excepts"
- Understand error flow through system
Implementation
- Extend AST extractor to walk try/except nodes
- Extract exception types from except handlers
- Use name resolution to map exception names to FQNs
- Create ExceptionType nodes (or reference existing classes)
- Create CATCHES relationships
- Update schema documentation
Related
Acceptance Criteria
User Outcome
A user can query which exceptions are caught where, trace error handling patterns, and identify unhandled exception types in the codebase.
Background
Currently we don't track exception handling. Knowing what exceptions are caught (and where) is valuable for:
except:clausesProposal
Extract exception information from try/except blocks:
Create relationships:
:Function -[:CATCHES]-> :ExceptionTypeExample Queries
Benefits
Implementation
Related
Acceptance Criteria