英文:
How can I tell which reason code an exception has thrown in JavaCard?
问题
我正在尝试查找为什么在我的小程序中引发了CryptoException
,但我很困惑。
我尝试了这个:
catch (CryptoException e) {
if (e instanceof CryptoException.ILLEGAL_USE) {
//发送特定的APDU
}
}
以及这个:
catch (CryptoException e) {
if (e == (short)5) {
//发送特定的APDU
}
}
还有这个:
catch (CryptoException e) {
if (e == CryptoException.ILLEGAL_USE) {
//发送特定的APDU
}
}
但似乎都不起作用,我找不到使用原因代码来发送特定APDU的正确方法。是否有一种方法可以做到这一点?
英文:
I'm trying to find out why a CryptoException
has been thrown in my applet but I'm struggling.
I've tried this:
catch (CryptoException e) {
if (e instanceof CryptoException.ILLEGAL_USE) {
//send certain apdu
}
}
And this:
catch (CryptoException e) {
if (e == (short)5) {
//send certain apdu
}
}
And also this:
catch (CryptoException e) {
if (e == CryptoException.ILLEGAL_USE) {
//SEND CERTAIN APDU
}
}
But none of them seem to work and I can't find the right way to use the reason code to send a specific apdu. Is there a way to do this?
答案1
得分: 1
调用 getReason()
在 CryptoException
上:
try {
// . . .
} catch (CryptoException e) {
if (e.getReason() == CryptoException.ILLEGAL_USE) {
// 发送特定的APDU
}
}
英文:
Call getReason()
on the CryptoException
:
try {
// . . .
} catch (CryptoException e) {
if (e.getReason() == CryptoException.ILLEGAL_USE) {
// SEND CERTAIN APDU
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论