3616d35a75
Migrates the 8 try/except sites in UI + theme + tooling files
by narrowing the exception types from broad 'except Exception' to
specific stdlib/domain exceptions.
Files and sites:
1. src/command_palette.py:120 (1 site) - command.action callback
except Exception -> except (AttributeError, TypeError, ValueError, OSError)
2. src/commands.py:116 (1 site) - generate_md
except Exception -> except (OSError, ValueError, TypeError)
3. src/commands.py:147 (1 site) - save_all
except Exception -> except (OSError, ValueError)
4. src/commands.py:271 (1 site) - reset_layout
except Exception -> except OSError
5. src/diff_viewer.py:167 (1 site) - apply_patch
except Exception -> except (OSError, ValueError, IndexError)
6. src/external_editor.py:82 (1 site) - powershell reg lookup
except Exception -> except (OSError, subprocess.SubprocessError,
subprocess.TimeoutExpired)
7. src/markdown_helper.py:123 (1 site) - open link
except Exception -> except (OSError, ValueError)
8. src/markdown_helper.py:200 (1 site) - render_table fallback
except Exception -> except (TypeError, AttributeError, ValueError, IndexError)
Also updates tests/test_command_palette_sim.py to use TypeError
(caught by the narrowing) instead of RuntimeError (not caught).
Decisions:
- theme_2.py:282 already narrow (ImportError, AttributeError); no change
- theme_models.py:166 is RAISE (not except); keep as-is (documented)
- external_editor.py:47, 56 already narrow (FileNotFoundError); no change
Tests verified:
- tests/test_command_palette.py (13 tests) PASS
- tests/test_command_palette_sim.py (7 tests) PASS
- tests/test_diff_viewer.py (10 tests) PASS
- tests/test_external_editor.py (16 tests) PASS
- tests/test_external_editor_gui.py (5 tests) PASS
- tests/test_markdown_helper_* (16 tests) PASS