|
13 | 13 | import org.usb4java.DeviceHandle; |
14 | 14 | import org.usb4java.DeviceList; |
15 | 15 | import org.usb4java.LibUsb; |
| 16 | +import org.usb4java.LibUsbException; |
16 | 17 |
|
17 | 18 | /** |
18 | 19 | * Dumps the descriptors of all available devices. |
@@ -43,8 +44,8 @@ public static void dumpConfigurationDescriptors(final Device device, |
43 | 44 | final int result = LibUsb.getConfigDescriptor(device, i, descriptor); |
44 | 45 | if (result < 0) |
45 | 46 | { |
46 | | - throw new RuntimeException( |
47 | | - "Unable to read config descriptor. Result=" + result); |
| 47 | + throw new LibUsbException("Unable to read config descriptor", |
| 48 | + result); |
48 | 49 | } |
49 | 50 | try |
50 | 51 | { |
@@ -97,8 +98,8 @@ public static void dumpDevice(final Device device) |
97 | 98 | int result = LibUsb.getDeviceDescriptor(device, descriptor); |
98 | 99 | if (result < 0) |
99 | 100 | { |
100 | | - throw new RuntimeException( |
101 | | - "Unable to read device descriptor. Result=" + result); |
| 101 | + throw new LibUsbException("Unable to read device descriptor", |
| 102 | + result); |
102 | 103 | } |
103 | 104 |
|
104 | 105 | // Try to open the device. This may fail because user has no |
@@ -143,17 +144,15 @@ public static void main(final String[] args) |
143 | 144 | int result = LibUsb.init(context); |
144 | 145 | if (result < 0) |
145 | 146 | { |
146 | | - throw new RuntimeException( |
147 | | - "Unable to initialize libusb. Result=" + result); |
| 147 | + throw new LibUsbException("Unable to initialize libusb", result); |
148 | 148 | } |
149 | 149 |
|
150 | 150 | // Read the USB device list |
151 | 151 | final DeviceList list = new DeviceList(); |
152 | 152 | result = LibUsb.getDeviceList(context, list); |
153 | 153 | if (result < 0) |
154 | 154 | { |
155 | | - throw new RuntimeException( |
156 | | - "Unable to get device list. Result=" + result); |
| 155 | + throw new LibUsbException("Unable to get device list", result); |
157 | 156 | } |
158 | 157 |
|
159 | 158 | try |
|
0 commit comments