From 650578113944338bca9988391776a8ec1654ff6c Mon Sep 17 00:00:00 2001 From: Pat Teruel Date: Sun, 1 Mar 2026 10:43:29 +0800 Subject: [PATCH] Add crash-safe launcher to mac_native.py: show dialog and write traceback to ~/media_episodes_viewer_error.log Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- mac_native.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/mac_native.py b/mac_native.py index da4de0c..8ff9abc 100644 --- a/mac_native.py +++ b/mac_native.py @@ -160,4 +160,26 @@ def main(): if __name__ == '__main__': - main() + try: + 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