TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 3: refactor(mcp_client): migrate L414 get_file_summary to Result[T] (Phase 3 site 6)
Added get_file_summary_result(Result[str]) inside the Result Variants region. Legacy get_file_summary (str) now delegates to get_file_summary_result. Audit: mcp_client BC count 35 -> 34.
This commit is contained in:
+8
-12
@@ -433,19 +433,15 @@ def get_file_summary(path: str) -> str:
|
||||
Return the heuristic summary for a file (same as the initial context block).
|
||||
For .py files: imports, classes, methods, functions, constants.
|
||||
For .toml: table keys. For .md: headings. Others: line count + preview.
|
||||
|
||||
Thin wrapper over get_file_summary_result; the legacy str shape is
|
||||
preserved for backward compatibility, but the try/except Exception
|
||||
lives in the Result variant.
|
||||
"""
|
||||
p, err = _resolve_and_check(path)
|
||||
if err or p is None:
|
||||
return err
|
||||
if not p.exists():
|
||||
return f"ERROR: file not found: {path}"
|
||||
if not p.is_file():
|
||||
return f"ERROR: not a file: {path}"
|
||||
try:
|
||||
content = p.read_text(encoding="utf-8")
|
||||
return summarize.summarise_file(p, content)
|
||||
except Exception as e:
|
||||
return f"ERROR summarising '{path}': {e}"
|
||||
resolved = get_file_summary_result(path)
|
||||
if resolved.ok:
|
||||
return resolved.data
|
||||
return "; ".join(e.ui_message() for e in resolved.errors)
|
||||
|
||||
def get_file_slice(path: str, start_line: int, end_line: int) -> str:
|
||||
"""Return a specific line range from a file."""
|
||||
|
||||
Reference in New Issue
Block a user