TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10: refactor(gui_2): migrate L612 _post_init callback to Result[T] (Phase 10 site 3)

Extracted _post_init_callback_result(app) -> Result[None] helper above
the App._post_init method.
ANTI-SLIMING: full Result[T] propagation (NO pass-after-logging). The
helper returns Result(data=None) on success or Result(data=None,
errors=[ErrorInfo]) on exception (logging NOT a drain per the user's
principle 2026-06-17).

The legacy _post_init method preserves its signature and calls the helper,
draining errors to self._startup_timeline_errors.

Tests: 2 new tests verify both paths (success and RuntimeError).

Audit: L612 reclassified from INTERNAL_SILENT_SWALLOW (10 sites remaining,
was 11). New helper L612 is INTERNAL_COMPLIANT.
This commit is contained in:
ed
2026-06-20 00:44:30 -04:00
parent 6585cdc5e7
commit e761244c4a
2 changed files with 78 additions and 13 deletions
+36 -13
View File
@@ -598,19 +598,42 @@ class App:
def _handle_save_anyway_click(self) -> None:
self._pending_save_anyway_click = True
def _post_init(self) -> None:
theme.apply_current()
# Register warmup completion callback (sub-track 4 of
# startup_speedup_20260606). The callback runs on a background
# _io_pool thread; it only sets primitive state on the App, which
# is safe. The render_warmup_status_indicator() function reads
# the timestamp to show a brief "ready" tag for 3 seconds.
if hasattr(self.controller, "on_warmup_complete"):
#Note(Ed): Exception(Thirdparty)
try:
self.controller.on_warmup_complete(lambda status: _on_warmup_complete_callback(self, status))
except Exception: pass
self._diag_layout_state()
def _post_init_callback_result(app: "App") -> Result[None]:
"""Drain-aware variant of App._post_init (L612 INTERNAL_SILENT_SWALLOW).
Extracts the controller.on_warmup_complete callback registration from
App._post_init into a Result-returning helper. On exception, returns
Result(data=None, errors=[ErrorInfo]) so the legacy wrapper can drain
the error to self._startup_timeline_errors. On success, the lambda
callback is registered and Result(data=None) is returned.
[C: src/gui_2.py:App._post_init (L612 legacy wrapper)]
"""
#Note(Ed): Exception(Thirdparty)
try:
app.controller.on_warmup_complete(lambda status: _on_warmup_complete_callback(app, status))
return Result(data=None)
except Exception as e:
return Result(data=None, errors=[ErrorInfo(
kind=ErrorKind.INTERNAL,
message=f"on_warmup_complete callback registration failed: {e}",
source="gui_2._post_init_callback_result",
original=e,
)])
def _post_init(self) -> None:
theme.apply_current()
# Register warmup completion callback (sub-track 4 of
# startup_speedup_20260606). The callback runs on a background
# _io_pool thread; it only sets primitive state on the App, which
# is safe. The render_warmup_status_indicator() function reads
# the timestamp to show a brief "ready" tag for 3 seconds.
if hasattr(self.controller, "on_warmup_complete"):
cb_result = _post_init_callback_result(self)
if not cb_result.ok:
if not hasattr(self, '_startup_timeline_errors'): self._startup_timeline_errors = []
self._startup_timeline_errors.append(("_post_init.callback", cb_result.errors[0]))
self._diag_layout_state()
def _diag_layout_state(self) -> None:
"""One-shot startup diagnostic: log show_windows state and warn if the