App: show startup errors in a message box and log them

mygarmin-app.exe has no console, so failures were silent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 13:12:41 +02:00
parent 462d23ba9d
commit 7b1276f0b1

View File

@@ -205,6 +205,18 @@ class Api:
def main(): def main():
"""Entry point of mygarmin-app.exe. It has no console, so any startup error is shown in a message box and logged."""
try: _main()
except BaseException as e:
if isinstance(e, SystemExit) and not e.code: raise
log = os.path.join(os.path.dirname(STATE), 'app.log'); os.makedirs(os.path.dirname(log), exist_ok=True)
open(log, 'a', encoding='utf-8').write(f'{datetime.now():%Y-%m-%d %H:%M:%S}\n{traceback.format_exc()}\n')
if sys.platform == 'win32':
import ctypes
ctypes.windll.user32.MessageBoxW(None, f'myGarmin could not start:\n\n{e}\n\nDetails: {log}', 'myGarmin', 0x10)
raise
def _main():
try: try:
import webview import webview
from webview.dom import DOMEventHandler from webview.dom import DOMEventHandler