Add try/catch around opening serial port and dump exception to console

Fixes #8
This commit is contained in:
Marcel Stör 2017-05-07 22:51:46 +02:00
parent a233e6f3f3
commit 9d1b526689
1 changed files with 9 additions and 1 deletions

10
Main.py
View File

@ -8,6 +8,7 @@ import esptool
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 @@ class FlashingThread(threading.Thread):
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 @@ class NodeMcuFlasher(wx.Frame):
about.ShowModal()
about.Destroy()
def report_error(self, message):
self.console_ctrl.SetValue(message)
# ---------------------------------------------------------------------------