ed
a7d8e2adfd
refactor(src): Phase 10.2 batch 2 - outline_tool Result[T] migration
...
Migrates 3 sites in src/outline_tool.py:
1. L49 (outline body) - the ast.parse SyntaxError handler.
outline() now returns Result[str]. On SyntaxError, the data
is the formatted error string (preserved for backwards-compat
with callers that read the formatted string), and the errors
list has the ErrorInfo.
2. L90 (walk ast.unparse for returns) - was except ...: pass.
Now appends ErrorInfo to enclosing parse_errors list.
3. L109 (walk ast.unparse for ImGui context) - same.
outline() returns Result(data='\n'.join(output), errors=parse_errors).
get_outline() also returns Result[str].
Tests updated to check result.ok and use result.data.
2026-06-17 22:31:35 -04:00
ed
a5b40bcff4
refactor(src): narrow exception types in Phase 7 batch (8 sites across 7 files)
...
Migrates the 8 try/except sites in Infrastructure + Hook + Utility
files by narrowing the exception types from broad 'except Exception'
to specific stdlib/domain exceptions.
Files and sites:
1. src/api_hooks.py:453 (HookHandler.do_GET error response)
except Exception -> except (OSError, ValueError)
2. src/api_hooks.py:826 (HookHandler.do_POST error response)
except Exception -> except (OSError, ValueError)
3. src/api_hooks.py:916 (websocket connection cleanup)
except Exception -> except (OSError, ValueError)
4. src/file_cache.py:84 (path mtime stat)
except Exception -> except (OSError, ValueError)
5. src/orchestrator_pm.py:37 (track metadata.json read)
except Exception -> except (OSError, json.JSONDecodeError, UnicodeDecodeError)
6. src/orchestrator_pm.py:49 (track spec.md read)
except Exception -> except (OSError, UnicodeDecodeError)
7. src/outline_tool.py:67 (ast.unparse node.returns)
except Exception -> except (ValueError, TypeError)
8. src/outline_tool.py:90 (ast.unparse ImGui context)
except Exception -> except (ValueError, TypeError, AttributeError)
9. src/shell_runner.py:99 (subprocess cleanup on error)
except Exception -> except (OSError, subprocess.SubprocessError)
10. src/summarize.py:187 (summarise_file fallback)
except Exception -> except (OSError, ValueError, TypeError, AttributeError)
11. src/summarize.py:191 (summarise_file outer)
except Exception -> except (OSError, ValueError, TypeError)
Decisions:
- src/api_hook_client.py: 0 violations; 2 compliant sites; no migration
- src/hot_reloader.py:58 - kept except Exception (module reload can
raise any exception; test fixture uses generic Exception)
- src/api_hooks.py:938-941 - RETHROW (keep as-is; cascading if changed)
Tests verified:
- tests/test_outline_tool.py (3 tests) PASS
- tests/test_hot_reloader.py (8 tests) PASS
- tests/test_hot_reload_integration.py (13 tests) PASS
2026-06-17 19:20:49 -04:00