mirror of
https://github.com/mik3y/usb-serial-for-android
synced 2025-06-07 16:06:10 +00:00
replace catch+throw with finally !ok, to get rid of UnhandledException shown as error
method declared as throwing only IOException, but unchecked exceptions can always happen
This commit is contained in:
parent
275590027b
commit
843792001f
@ -117,6 +117,7 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
|||||||
throw new IllegalArgumentException("Connection is null");
|
throw new IllegalArgumentException("Connection is null");
|
||||||
}
|
}
|
||||||
mConnection = connection;
|
mConnection = connection;
|
||||||
|
boolean ok = false;
|
||||||
try {
|
try {
|
||||||
openInt();
|
openInt();
|
||||||
if (mReadEndpoint == null || mWriteEndpoint == null) {
|
if (mReadEndpoint == null || mWriteEndpoint == null) {
|
||||||
@ -124,11 +125,13 @@ public abstract class CommonUsbSerialPort implements UsbSerialPort {
|
|||||||
}
|
}
|
||||||
mUsbRequest = new UsbRequest();
|
mUsbRequest = new UsbRequest();
|
||||||
mUsbRequest.initialize(mConnection, mReadEndpoint);
|
mUsbRequest.initialize(mConnection, mReadEndpoint);
|
||||||
} catch(Exception e) {
|
ok = true;
|
||||||
|
} finally {
|
||||||
|
if (!ok) {
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
} catch(Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
throw e;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user