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:
@@ -205,6 +205,18 @@ class Api:
|
||||
|
||||
|
||||
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:
|
||||
import webview
|
||||
from webview.dom import DOMEventHandler
|
||||
|
||||
Reference in New Issue
Block a user