diff --git a/trunner/tools/phoenix.py b/trunner/tools/phoenix.py index f3f14d1b6..adaf08579 100644 --- a/trunner/tools/phoenix.py +++ b/trunner/tools/phoenix.py @@ -4,6 +4,7 @@ import threading import time import pexpect +import traceback from trunner.harness import ProcessError from serial.tools import list_ports @@ -24,7 +25,7 @@ def wait_for_vid_pid(vid: int, pid: int, timeout=0): found_ports = [port for port in list_ports.comports() if port.pid == pid and port.vid == vid] if len(found_ports) > 1: - raise Exception( + raise AssertionError( "More than one plo port was found! Maybe more than one device is connected? Hint used to find port:" f"{vid:04x}:{pid:04x}" ) @@ -119,8 +120,10 @@ def _run(self): # such wait avoids a following issue with loading an app: # https://github.com/phoenix-rtos/phoenix-rtos-project/issues/545 time.sleep(0.5) - except (TimeoutError, Exception) as exc: - raise PhoenixdError(str(exc)) from exc + except (TimeoutError, AssertionError) as exc: + raise PhoenixdError(msg=str(exc)) from exc + except Exception as exc: + raise PhoenixdError(msg=str(exc), output=traceback.format_exc()) from exc # Use pexpect.spawn to run a process as PTY, so it will flush on a new line self.proc = pexpect.spawn(