From 3c1a359c2816cef240c685ff99b53bf49ea18356 Mon Sep 17 00:00:00 2001 From: uniederer Date: Sun, 3 Feb 2013 17:02:21 +0000 Subject: [PATCH] Added Error codes git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@307 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c --- .../libusbJava/exceptions/LibusbError.java | 21 +++++++++++++++++++ .../test/exceptions/LibusbErrorTest.java | 5 ++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/java/src/ch/ntb/inf/libusbJava/exceptions/LibusbError.java b/java/src/ch/ntb/inf/libusbJava/exceptions/LibusbError.java index 907e47d..7f28e78 100644 --- a/java/src/ch/ntb/inf/libusbJava/exceptions/LibusbError.java +++ b/java/src/ch/ntb/inf/libusbJava/exceptions/LibusbError.java @@ -20,6 +20,9 @@ public class LibusbError extends Exception { public static final int ERROR_NO_MEM = -11; public static final int ERROR_NOT_SUPPORTED = -12; public static final int ERROR_OTHER = -99; + public static final int ERROR_JAVA_REFERENCES_NOT_LOADED = -100; + public static final int ERROR_JAVA_WRONG_ENVIRONMENT = -101; + public static final int ERROR_JAVA_ILEGAL_DEVICE_HANDLE = -102; private int code = ERROR_NONE; @@ -113,6 +116,24 @@ public class LibusbError extends Exception { break; } + case ERROR_JAVA_REFERENCES_NOT_LOADED: + { + result = "ERROR_JAVA_REFERENCES_NOT_LOADED"; + break; + } + + case ERROR_JAVA_WRONG_ENVIRONMENT: + { + result = "ERROR_JAVA_WRONG_ENVIRONMENT"; + break; + } + + case ERROR_JAVA_ILEGAL_DEVICE_HANDLE: + { + result = "ERROR_JAVA_ILEGAL_DEVICE_HANDLE"; + break; + } + default: { result = "ERROR_UNKNWON (" + code + ")"; diff --git a/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java b/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java index 0d5e53a..db0b2be 100644 --- a/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java +++ b/java/test/ch/ntb/inf/libusbJava/test/exceptions/LibusbErrorTest.java @@ -31,7 +31,10 @@ public class LibusbErrorTest { {"ERROR_NOT_SUPPORTED", -12}, {"ERROR_UNKNWON (-13)", -13}, {"ERROR_UNKNWON (-98)", -98}, - {"ERROR_UNKNWON (-100)", -100}, + {"ERROR_JAVA_REFERENCES_NOT_LOADED", -100}, + {"ERROR_JAVA_WRONG_ENVIRONMENT", -101}, + {"ERROR_JAVA_ILEGAL_DEVICE_HANDLE", -102}, + {"ERROR_UNKNWON (-103)", -103}, {"ERROR_OTHER", -99} }); }