Private
Public Access
0
0

TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 3: refactor(mcp_client): migrate L266 read_file to Result[T] (Phase 3 site 4)

Legacy read_file (str) now delegates to read_file_result (Result[str]).
The try/except Exception is REMOVED.

Audit: mcp_client BC count 37 -> 36.
This commit is contained in:
2026-06-20 08:29:16 -04:00
parent dc41cb3775
commit da9c5419ef
+10 -10
View File
@@ -221,16 +221,16 @@ def list_directory(path: str) -> str:
return "; ".join(e.ui_message() for e in resolved.errors)
def read_file(path: str) -> str:
"""Return the UTF-8 content of a file, or an error string."""
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:
return p.read_text(encoding="utf-8")
except Exception as e:
return f"ERROR reading '{path}': {e}"
"""Return the UTF-8 content of a file, or an error string.
Thin wrapper over read_file_result; the legacy str shape is preserved
for backward compatibility, but the try/except Exception lives in
the Result variant.
"""
resolved = read_file_result(path)
if resolved.ok:
return resolved.data
return "; ".join(e.ui_message() for e in resolved.errors)
#region: Result Variants
def _resolve_and_check_result(raw_path: str) -> Result[Path]: