From 7328f10165755d3a71c77790cc7b2637d79681b2 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Tue, 21 Sep 2021 10:12:48 +0200 Subject: [PATCH] transport/init: print exception type if the execption has no string There may be corner cases where an execption contains no error message. In this case it might still be helpful to display the type of the exeption calss to get at least an idea of what kind of error we are dealing with. Change-Id: I6e6b3acd17e40934050b9b088960a2f851120b26 --- pySim/transport/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py index dae2a782..72a80a96 100644 --- a/pySim/transport/__init__.py +++ b/pySim/transport/__init__.py @@ -234,5 +234,8 @@ def init_reader(opts, **kwargs) -> Optional[LinkBase]: sl = SerialSimLink(device=opts.device, baudrate=opts.baudrate, **kwargs) return sl except Exception as e: - print("Card reader initialization failed with exception:\n" + str(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