Private
Public Access
TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 8: refactor(gui_2): migrate L897 _capture_workspace_profile to Result[T] (Phase 8)
Migrate the imgui.save_ini_settings_to_memory try/except in App._capture_workspace_profile (L897) to the canonical Result[T] pattern: - Extract _capture_workspace_profile_ini_result(app) -> Result[str] helper into Phase 8 Property Setter / State Result Helpers region. - The legacy _capture_workspace_profile method calls the helper and drains errors to app._last_request_errors (per FR-BC-4 event-handler drain pattern; this is a property setter on the App). - The original fallback behavior (ini = '' on failure) is preserved so the legacy WorkspaceProfile still constructs with empty ini_content. Tests: - test_phase_8_l897_capture_workspace_profile_ini_result_success - test_phase_8_l897_capture_workspace_profile_ini_result_failure Audit: INTERNAL_BROAD_CATCH count in src/gui_2.py is now 0. All 22 INTERNAL_BROAD_CATCH sites originally in src/gui_2.py have been migrated to Result[T] across Phases 3-8.
This commit is contained in:
+31
-3
@@ -891,9 +891,13 @@ class App:
|
||||
self._ini_capture_ready = True
|
||||
ini = ""
|
||||
else:
|
||||
#Note(Ed): Thirdparty Exception
|
||||
try: ini = str(imgui.save_ini_settings_to_memory() or "")
|
||||
except Exception: ini = ""
|
||||
ini_result = _capture_workspace_profile_ini_result(self)
|
||||
if ini_result.ok:
|
||||
ini = ini_result.data
|
||||
else:
|
||||
if not hasattr(self, "_last_request_errors"): self._last_request_errors = []
|
||||
self._last_request_errors.append(("_capture_workspace_profile", ini_result.errors[0]))
|
||||
ini = ""
|
||||
panel_states = {
|
||||
"ui_separate_context_preview": getattr(self, "ui_separate_context_preview", False),
|
||||
"ui_separate_message_panel": getattr(self, "ui_separate_message_panel", False),
|
||||
@@ -8128,6 +8132,30 @@ def _diag_layout_state_ini_text_result(app: "App", ini_path: str) -> Result[str]
|
||||
original=e,
|
||||
)])
|
||||
|
||||
def _capture_workspace_profile_ini_result(app: "App") -> Result[str]:
|
||||
"""Drain-aware variant of L897 _capture_workspace_profile ini-capture try block.
|
||||
|
||||
Extracts the thirdparty imgui.save_ini_settings_to_memory try/except
|
||||
from App._capture_workspace_profile into a Result-returning helper.
|
||||
On exception, returns Result(data="", errors=[ErrorInfo]) so the legacy
|
||||
wrapper can fall back to the empty-string ini content. On success,
|
||||
returns Result(data=ini_str) where ini_str is the serialized INI content.
|
||||
The legacy wrapper drains errors to app._last_request_errors (per FR-BC-4
|
||||
event-handler drain pattern; this site is a property setter on the App).
|
||||
|
||||
[C: src/gui_2.py:App._capture_workspace_profile (L897 legacy wrapper)]
|
||||
"""
|
||||
try:
|
||||
ini = str(imgui.save_ini_settings_to_memory() or "")
|
||||
return Result(data=ini)
|
||||
except Exception as e:
|
||||
return Result(data="", errors=[ErrorInfo(
|
||||
kind=ErrorKind.INTERNAL,
|
||||
message=f"imgui.save_ini_settings_to_memory failed: {e}",
|
||||
source="gui_2._capture_workspace_profile_ini_result",
|
||||
original=e,
|
||||
)])
|
||||
|
||||
#endregion: Phase 8 Property Setter / State Result Helpers
|
||||
|
||||
#endregion: MMA
|
||||
|
||||
Reference in New Issue
Block a user