Debug Java Card applets and understand the cause of exception

361 views Asked by At

I'm going to develop java SIM toolkit applets. One of my difficulties is when I have an exception in my code I don't know how to understand what is the exception?

try {
        reg.initMenuEntry(MenuItem1, (short) 0, (short) MenuItem1.length, PRO_CMD_DISPLAY_TEXT, false, (byte) 0, (short) 0);
} catch (Throwable t) {

}

E.g. in above statement if an exception happens, I don't know how to handle the exception and understand what is the cause of exception?

P.s. Is catching Throwable a good idea (instead of exception)? I tried to catch Throwable since it is parent of Exception itself.

1

There are 1 answers

4
Paul Bastian On

Some JavaCard platforms come along with a debugger, but this is mostly depending on the vendor, so you have to contact your supplier/vendor.

For some easy lightweight debugging, you can catch Exception and compare this with the different specific Exceptions provided by the documentation and throw specific ISOException errors, in that way if it crashes you don't always get 0x6f00, but you could throw 0x6f01 for OutofBoundsException, 0x6f02 for NullPointerException and so on...