mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-22 13:21:03 +00:00
transport: report proper exception when no device found
This commit is contained in:
parent
897bc14a36
commit
6fa8ccfeed
@ -133,8 +133,8 @@ def get_transport(path: str = None, prefix_search: bool = False) -> Transport:
|
|||||||
if path is None:
|
if path is None:
|
||||||
try:
|
try:
|
||||||
return next(iter(enumerate_devices()))
|
return next(iter(enumerate_devices()))
|
||||||
except IndexError:
|
except StopIteration:
|
||||||
raise Exception("No TREZOR device found") from None
|
raise TransportException("No TREZOR device found") from None
|
||||||
|
|
||||||
# Find whether B is prefix of A (transport name is part of the path)
|
# 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).
|
# 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:
|
if transports:
|
||||||
return transports[0].find_by_path(path, prefix_search=prefix_search)
|
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))
|
||||||
|
Loading…
Reference in New Issue
Block a user