1
0
mirror of https://github.com/mik3y/usb-serial-for-android synced 2025-06-07 07:56:20 +00:00

improve error quality + test for PR #339

This commit is contained in:
kai-morich 2021-01-31 19:56:43 +01:00
parent fc610a9764
commit 85d0348844
2 changed files with 4 additions and 1 deletions

View File

@ -1846,7 +1846,7 @@ public class DeviceTest {
try {
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD, UsbWrapper.OpenCloseFlags.NO_DEVICE_CONNECTION));
fail("open error expected");
} catch (IOException ignored) {
} catch (Exception ignored) {
}
usb.open(EnumSet.of(UsbWrapper.OpenCloseFlags.NO_IOMANAGER_THREAD));

View File

@ -93,6 +93,9 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
if (mConnection != null) {
throw new IOException("Already open");
}
if(connection == null) {
throw new IllegalArgumentException("Connection is null");
}
mConnection = connection;
try {
openInt(connection);