From 9d1b526689b07ee9fd4d7614ec609338270b4bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20St=C3=B6r?= Date: Sun, 7 May 2017 22:51:46 +0200 Subject: [PATCH] Add try/catch around opening serial port and dump exception to console Fixes #8 --- Main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Main.py b/Main.py index 38c7958..7c2b156 100644 --- a/Main.py +++ b/Main.py @@ -8,6 +8,7 @@ import threading import json import images as images +from serial import SerialException from serial.tools import list_ports from esptool import ESPROM from argparse import Namespace @@ -57,7 +58,11 @@ def __init__(self, parent, config): self._config = config def run(self): - esp = ESPROM(port=self._config.port) + try: + esp = ESPROM(port=self._config.port) + except SerialException as e: + self._parent.report_error(e.strerror) + raise e args = Namespace() args.flash_size = "detect" args.flash_mode = self._config.mode @@ -318,6 +323,9 @@ def _on_help_about(self, event): about.ShowModal() about.Destroy() + def report_error(self, message): + self.console_ctrl.SetValue(message) + # ---------------------------------------------------------------------------