Private
Public Access
TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10: refactor(gui_2): migrate L1052 shutdown save_ini to Result[T] (Phase 10 site 5)
Extracted _shutdown_save_ini_result(app) -> Result[None] helper above the App.shutdown method. ANTI-SLIMING: full Result[T] propagation (NO bare-except+pass). 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 shutdown method preserves its signature, calls the helper, drains errors to self._startup_timeline_errors, and proceeds to self.controller.shutdown(). Tests: 2 new tests verify both paths (success and OSError). Audit: L1052 reclassified from INTERNAL_SILENT_SWALLOW (9 sites remaining, was 10). New helper L1052 is INTERNAL_COMPLIANT.
This commit is contained in:
+27
-6
@@ -1045,14 +1045,35 @@ def _run_immapp_result(app: "App") -> Result[None]:
|
||||
forces a save of dirty registries/caches, and terminates the active thread pools.
|
||||
SSDL Shape: `[I:save_ini] -> [I:controller_shutdown]`
|
||||
"""
|
||||
#Note(Ed): Exception(Thirdparty)
|
||||
try:
|
||||
if hasattr(self, 'runner_params') and self.runner_params.ini_filename:
|
||||
imgui.save_ini_settings_to_disk(self.runner_params.ini_filename)
|
||||
except:
|
||||
pass
|
||||
ini_result = _shutdown_save_ini_result(self)
|
||||
if not ini_result.ok:
|
||||
if not hasattr(self, '_startup_timeline_errors'): self._startup_timeline_errors = []
|
||||
self._startup_timeline_errors.append(("shutdown.save_ini", ini_result.errors[0]))
|
||||
self.controller.shutdown()
|
||||
|
||||
def _shutdown_save_ini_result(app: "App") -> Result[None]:
|
||||
"""Drain-aware variant of App.shutdown save_ini try block (L1052 INTERNAL_SILENT_SWALLOW).
|
||||
|
||||
Extracts the thirdparty imgui.save_ini_settings_to_disk try/except from
|
||||
App.shutdown into a Result-returning helper. On exception, converts to
|
||||
ErrorInfo (logging NOT a drain per the user's principle 2026-06-17). The
|
||||
legacy shutdown method drains to self._startup_timeline_errors.
|
||||
|
||||
[C: src/gui_2.py:App.shutdown (L1052 legacy wrapper)]
|
||||
"""
|
||||
#Note(Ed): Exception(Thirdparty)
|
||||
try:
|
||||
if hasattr(app, 'runner_params') and app.runner_params.ini_filename:
|
||||
imgui.save_ini_settings_to_disk(app.runner_params.ini_filename)
|
||||
return Result(data=None)
|
||||
except Exception as e:
|
||||
return Result(data=None, errors=[ErrorInfo(
|
||||
kind=ErrorKind.INTERNAL,
|
||||
message=f"imgui.save_ini_settings_to_disk failed: {e}",
|
||||
source="gui_2._shutdown_save_ini_result",
|
||||
original=e,
|
||||
)])
|
||||
|
||||
def load_context_preset(self, name: str) -> None:
|
||||
preset = self.controller.load_context_preset(name)
|
||||
from src import models
|
||||
|
||||
Reference in New Issue
Block a user