diff options
author | Harald Welte <laforge@osmocom.org> | 2021-01-21 14:10:43 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-01-21 16:11:39 +0100 |
commit | fd72b95dd6d4c5572b7826ce5889aac863a8a543 (patch) | |
tree | 2c3fc6a70631e55437e204f0f2902991c206b67a /pySim/exceptions.py | |
parent | 19b286d46088b88d95b1007571fbdaa387a9d06c (diff) |
introduce SwMatchError exception
This allows callers further up the stack to catch the exception and
interpret it in some way (like decoding the number of remaining tries
in case of authentication errors)
Change-Id: Ia59962978745aef7038f750fa23f8dfc820645f4
Diffstat (limited to 'pySim/exceptions.py')
-rw-r--r-- | pySim/exceptions.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pySim/exceptions.py b/pySim/exceptions.py index 68303e1..e959a70 100644 --- a/pySim/exceptions.py +++ b/pySim/exceptions.py @@ -6,6 +6,7 @@ # # Copyright (C) 2009-2010 Sylvain Munaut <tnt@246tNt.com> +# Copyright (C) 2021 Harald Welte <laforge@osmocom.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,3 +38,12 @@ class ProtocolError(Exception): class ReaderError(Exception): pass + +class SwMatchError(Exception): + """Raised when an operation specifies an expected SW but the actual SW from + the card doesn't match.""" + def __init__(self, sw_actual, sw_expected): + self.sw_actual = sw_actual + self.sw_expected = sw_expected + def __str__(self): + return "Received %s but expected %s from card" % (self.sw_actual, self.sw_expected) |