pySim-shell: print device info in case an exception occurs

When an exception occurs while initializing or handling the card we
print a traceback, but we do not print any info that allows us to
identify the device that was involved when the exception occurred. Let's
include the device path or number in the error message before we print
the traceback.

In order to make it easier to print the device information, let's add a
__str__() method to all of our devices. This method shall return the
device number or path.

Related: OS#6210
Change-Id: I200463e692245da40ea6d5b609bfc0ca02d15bdb
This commit is contained in:
Philipp Maier
2023-10-09 13:32:49 +02:00
parent 8e03f2f2ed
commit 6bfa8a8533
7 changed files with 26 additions and 3 deletions

View File

@@ -67,6 +67,10 @@ class LinkBase(abc.ABC):
self.apdu_tracer = apdu_tracer
self.proactive_handler = proactive_handler
@abc.abstractmethod
def __str__(self):
"""Implementation specific method for printing an information to identify the device."""
@abc.abstractmethod
def _send_apdu_raw(self, pdu: Hexstr) -> ResTuple:
"""Implementation specific method for sending the PDU."""