From 6fa8ccfeed47752674872bb5bc68c2011a171b34 Mon Sep 17 00:00:00 2001 From: matejcik Date: Tue, 8 Jan 2019 14:27:21 +0100 Subject: [PATCH] transport: report proper exception when no device found --- trezorlib/transport/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trezorlib/transport/__init__.py b/trezorlib/transport/__init__.py index 173c7f0bc2..c81d998b43 100644 --- a/trezorlib/transport/__init__.py +++ b/trezorlib/transport/__init__.py @@ -133,8 +133,8 @@ def get_transport(path: str = None, prefix_search: bool = False) -> Transport: if path is None: try: return next(iter(enumerate_devices())) - except IndexError: - raise Exception("No TREZOR device found") from None + except StopIteration: + raise TransportException("No TREZOR device found") from None # Find whether B is prefix of A (transport name is part of the path) # or A is prefix of B (path is a prefix, or a name, of transport). @@ -151,4 +151,4 @@ def get_transport(path: str = None, prefix_search: bool = False) -> Transport: if transports: return transports[0].find_by_path(path, prefix_search=prefix_search) - raise Exception("Could not find device by path: {}".format(path)) + raise TransportException("Could not find device by path: {}".format(path))