Skip to content

Commit 96875a8

Browse files
Merge pull request #235 from LedgerHQ/apduexception
Added 'data' argument to ApduException; made args mandatory
2 parents c1092c4 + 5eba889 commit 96875a8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

speculos/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515

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

2122

2223
class ClientException(Exception):
@@ -38,7 +39,7 @@ def receive(self) -> bytes:
3839
check_status_code(self.response, "/apdu")
3940
data, status = split_apdu(bytes.fromhex(self.response.json()["data"]))
4041
if status != 0x9000:
41-
raise ApduException(status)
42+
raise ApduException(status, data)
4243
return data
4344

4445

0 commit comments

Comments
 (0)