Skip to content

Commit

Permalink
Merge pull request #235 from LedgerHQ/apduexception
Browse files Browse the repository at this point in the history
Added 'data' argument to ApduException; made args mandatory
  • Loading branch information
niooss-ledger authored Jul 29, 2021
2 parents c1092c4 + 5eba889 commit 96875a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions speculos/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@


class ApduException(Exception):
def __init__(self, sw: int = 0x6F00) -> None:
def __init__(self, sw: int, data: bytes) -> None:
super().__init__(f"Exception: invalid status 0x{sw:x}")
self.sw = sw
self.data = data


class ClientException(Exception):
Expand All @@ -38,7 +39,7 @@ def receive(self) -> bytes:
check_status_code(self.response, "/apdu")
data, status = split_apdu(bytes.fromhex(self.response.json()["data"]))
if status != 0x9000:
raise ApduException(status)
raise ApduException(status, data)
return data


Expand Down

0 comments on commit 96875a8

Please sign in to comment.