Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current owner to PortInUseException #2126

Merged
merged 2 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ public SerialPort open(String owner, int timeout) throws PortInUseException {
String.format("We expect an serial port instead of '%s'", cp.getClass()));
}
} catch (javax.comm.PortInUseException e) {
throw new PortInUseException();
String message = e.getMessage();
if (message != null) {
throw new PortInUseException(message, e);
} else {
throw new PortInUseException(e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public SerialPort open(String owner, int timeout) throws PortInUseException {
String.format("We expect an serial port instead of '%s'", cp.getClass()));
}
} catch (gnu.io.PortInUseException e) {
throw new PortInUseException();
String message = e.getMessage();
if (message != null) {
throw new PortInUseException(message, e);
} else {
throw new PortInUseException(e);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@
public class PortInUseException extends Exception {

private static final long serialVersionUID = -2709480420743139383L;

public PortInUseException(String message, Exception cause) {
super(message, cause);
}

public PortInUseException(Exception cause) {
super(cause);
}
}