transport: do not catch exceptions in init_reader

We currently catch any exceptions that may occur when the card reader is
initialized. Then we print the exception string or the exception type
when no string is available. However, a failure during the reader
initialization is usually a severe problem, so a traceback would provde
a lot of helpful information to debug the issue. So lets not catch any
exceptions at this level so that we get the full backtrace.

Related: OS#6210
Change-Id: I4c4807576fe63cf71a7d33b243a3f8fea0b7ff23
This commit is contained in:
Philipp Maier 2023-10-10 12:29:14 +02:00
parent 58e89eb15a
commit af4e5bb18c
4 changed files with 20 additions and 35 deletions

View File

@ -794,8 +794,6 @@ if __name__ == '__main__':
# Init card reader driver
sl = init_reader(opts)
if sl is None:
exit(1)
# Create command layer
scc = SimCardCommands(transport=sl)

View File

@ -74,8 +74,6 @@ if __name__ == '__main__':
# Init card reader driver
sl = init_reader(opts)
if sl is None:
exit(1)
# Create command layer
scc = SimCardCommands(transport=sl)

View File

@ -1015,8 +1015,6 @@ if __name__ == '__main__':
# Init card reader driver
sl = init_reader(opts, proactive_handler = Proact())
if sl is None:
exit(1)
# Create a card handler (for bulk provisioning)
if opts.card_handler_config:

View File

@ -292,12 +292,10 @@ def argparse_add_reader_args(arg_parser):
return arg_parser
def init_reader(opts, **kwargs) -> Optional[LinkBase]:
def init_reader(opts, **kwargs) -> LinkBase:
"""
Init card reader driver
"""
sl = None # type : :Optional[LinkBase]
try:
if opts.pcsc_dev is not None:
print("Using PC/SC reader interface")
from pySim.transport.pcsc import PcscSimLink
@ -317,10 +315,3 @@ def init_reader(opts, **kwargs) -> Optional[LinkBase]:
sl = SerialSimLink(device=opts.device,
baudrate=opts.baudrate, **kwargs)
return sl
except Exception as e:
if str(e):
print("Card reader initialization failed with exception:\n" + str(e))
else:
print(
"Card reader initialization failed with an exception of type:\n" + str(type(e)))
return None