Add crash-safe launcher to mac_native.py: show dialog and write traceback to ~/media_episodes_viewer_error.log

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Pat TeruelandCopilot committed 2026-03-01 10:43:29 +08:00
1 parent 4de3064dd1
commit 6505781139
1 file changed
+22
+22
View File
@@ -160,4 +160,26 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
try:
main() main()
except Exception as e:
import traceback, sys, os
tb = traceback.format_exc()
# Try to show a GUI error dialog if possible
try:
import tkinter as _tk
from tkinter import messagebox as _mb
_root = _tk.Tk()
_root.withdraw()
_mb.showerror("Launch Error", f"Error starting app:\n{e}\n\nA log was written to ~/media_episodes_viewer_error.log")
_root.destroy()
except Exception:
pass
# Always write traceback to a known file for debugging
try:
with open(os.path.expanduser('~/media_episodes_viewer_error.log'), 'w') as fh:
fh.write(tb)
except Exception:
pass
# Re-raise so py2app shows the launch error dialog as well
raise