X-Git-Url: http://www.average.org/gitweb/?p=YkNeoCR.git;a=blobdiff_plain;f=src%2Forg%2Faverage%2Fnfcauthcr%2FYkNeo.java;h=6dcaf640f4d84bdca90ecf8395421d0772da4790;hp=26a685350657228170874dc39dc24042e47cc21a;hb=6f022e1e8402cf131c166bd98be511b7fc899fec;hpb=eed939e04ff795ee6e5fbfd0297c26c6996a2fd9 diff --git a/src/org/average/nfcauthcr/YkNeo.java b/src/org/average/nfcauthcr/YkNeo.java index 26a6853..6dcaf64 100644 --- a/src/org/average/nfcauthcr/YkNeo.java +++ b/src/org/average/nfcauthcr/YkNeo.java @@ -1,5 +1,6 @@ package org.average.nfcauthcr; +import java.lang.String; import java.io.IOException; import java.util.Arrays; @@ -32,8 +33,9 @@ public class YkNeo { int length = resp.length; if (resp[length - 2] != (byte)0x90 || resp[length - 1] != 0x00) { - throw new CRException( - "NFC Error code in the response to select"); + throw new CRException(String.format( + "NFC select error code: %02x:%02x", + resp[length - 2], resp[length - 1])); } byte[] crApdu = new byte[69]; crApdu[0] = 0x00; // CLA @@ -51,18 +53,20 @@ public class YkNeo { length = resp.length; if (resp[length - 2] != (byte)0x90 || resp[length - 1] != 0x00) { - throw new CRException( - "NFC Error code in the response to CR"); + throw new CRException(String.format( + "NFC CR error code: %02x:%02x", + resp[length - 2], resp[length - 1])); } if (length != 22) { - throw new CRException( - "NFC wrong response size: " + (length-2)); + throw new CRException(String.format( + "NFC wrong response size: got %d, need 20", + length-2)); } return Arrays.copyOf(resp, length-2); } catch (TagLostException e) { throw new CRException("NFC connection lost", e); } catch (IOException e) { - throw new CRException("NFC I/O error", e); + throw new CRException("NFC I/O: " + e.getMessage(), e); } } }