Skip to content

Commit

Permalink
Add current owner to PortInUseException
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian Wolter <[email protected]>
  • Loading branch information
Fabian Wolter committed Jan 17, 2021
1 parent 127724c commit 73048ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
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);
} else {
throw new PortInUseException();
}
}
}

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);
} else {
throw new PortInUseException();
}
}
}

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() {
super();
}

public PortInUseException(String message) {
super(message);
}
}

0 comments on commit 73048ef

Please sign in to comment.