dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/pysim/+/35101?usp=email )


Change subject: app: do not catch exceptions in init_card
......................................................................

app: do not catch exceptions in init_card

The function init_card catches all exceptions and then returns None
objects for card or rs in case of an error. This does not fit in the
style we pursue in pySim. This is in particular true for library
functions. We want those functions to raise exceptions when something is
wrong, so that we can catch the exception at top level. Let's fix this
for init_card now.

Related: OS#6271
Change-Id: I581125d8273ef024f6dbf3a5db6116be15c5c95d
---
M pySim/app.py
1 file changed, 19 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/01/35101/1

diff --git a/pySim/app.py b/pySim/app.py
index 1711a1c..5a9f772 100644
--- a/pySim/app.py
+++ b/pySim/app.py
@@ -55,14 +55,7 @@
     # Wait up to three seconds for a card in reader and try to detect
     # the card type.
     print("Waiting for card...")
-    try:
-        sl.wait_for_card(3)
-    except NoCardError:
-        print("No card detected!")
-        return None, None
-    except:
-        print("Card not readable!")
-        return None, None
+    sl.wait_for_card(3)

     generic_card = False
     card = card_detect(scc)
@@ -73,8 +66,7 @@

     profile = CardProfile.pick(scc)
     if profile is None:
-        print("Unsupported card type!")
-        return None, card
+        raise ValueError("Unsupported card type!")

     # ETSI TS 102 221, Table 9.3 specifies a default for the PIN key
     # references, however card manufactures may still decide to pick an

--
To view, visit https://gerrit.osmocom.org/c/pysim/+/35101?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I581125d8273ef024f6dbf3a5db6116be15c5c95d
Gerrit-Change-Number: 35101
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to