pySim.commands: Don't convert SwMatchError to ValueError
In the read and write command implementations, we used to catch lower-layer exceptions (usually SwMatchError) and "translate" that into a value error, only to add more information to the exception. This meant that higher-layer code could no longer detect this was actually a SwMatchError exception type. Let's instead use the add_note() method to amend the existing exception, rather than raising a new one of different type. Change-Id: Ic94d0fe60a8a5e15aade56ec418192ecf31ac5e7
This commit is contained in:
@@ -334,8 +334,8 @@ class SimCardCommands:
|
||||
try:
|
||||
data, sw = self.send_apdu_checksw(pdu)
|
||||
except Exception as e:
|
||||
raise ValueError('%s, failed to read (offset %d)' %
|
||||
(str_sanitize(str(e)), offset)) from e
|
||||
e.add_note('failed to read (offset %d)' % offset)
|
||||
raise e
|
||||
total_data += data
|
||||
chunk_offset += chunk_len
|
||||
return total_data, sw
|
||||
@@ -394,8 +394,8 @@ class SimCardCommands:
|
||||
try:
|
||||
chunk_data, chunk_sw = self.send_apdu_checksw(pdu)
|
||||
except Exception as e:
|
||||
raise ValueError('%s, failed to write chunk (chunk_offset %d, chunk_len %d)' %
|
||||
(str_sanitize(str(e)), chunk_offset, chunk_len)) from e
|
||||
e.add_note('failed to write chunk (chunk_offset %d, chunk_len %d)' % (chunk_offset, chunk_len))
|
||||
raise e
|
||||
total_data += data
|
||||
chunk_offset += chunk_len
|
||||
if verify:
|
||||
|
||||
Reference in New Issue
Block a user