Skip to content

Commit

Permalink
Add try/catch around opening serial port and dump exception to console
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
marcelstoer committed May 7, 2017
1 parent a233e6f commit 9d1b526
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -318,6 +323,9 @@ def _on_help_about(self, event):
about.ShowModal()
about.Destroy()

def report_error(self, message):
self.console_ctrl.SetValue(message)

# ---------------------------------------------------------------------------


Expand Down

0 comments on commit 9d1b526

Please sign in to comment.