add better exception handling
This commit is contained in:
parent
b7f9df6383
commit
a0c15da432
|
@ -266,11 +266,11 @@ public class WalletApplet extends Applet {
|
|||
break;
|
||||
}
|
||||
} catch(ISOException sw) {
|
||||
if (shouldRespond(apdu) && (sw.getReason() != ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED)) {
|
||||
secureChannel.respond(apdu, (short) 0, sw.getReason());
|
||||
} else {
|
||||
throw sw;
|
||||
}
|
||||
handleException(apdu, sw.getReason());
|
||||
} catch (CryptoException ce) {
|
||||
handleException(apdu, (short)(ISO7816.SW_UNKNOWN | ce.getReason()));
|
||||
} catch (Exception e) {
|
||||
handleException(apdu, ISO7816.SW_UNKNOWN);
|
||||
}
|
||||
|
||||
if (shouldRespond(apdu)) {
|
||||
|
@ -278,6 +278,14 @@ public class WalletApplet extends Applet {
|
|||
}
|
||||
}
|
||||
|
||||
private void handleException(APDU apdu, short sw) {
|
||||
if (shouldRespond(apdu) && (sw != ISO7816.SW_SECURITY_STATUS_NOT_SATISFIED)) {
|
||||
secureChannel.respond(apdu, (short) 0, sw);
|
||||
} else {
|
||||
ISOException.throwIt(sw);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes the init command, this is invoked only if the applet has not yet been personalized with secrets.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue