mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add DeviceNotFound Error
This commit is contained in:
parent
cadcc6c8ef
commit
b5d4a5000b
2 changed files with 12 additions and 1 deletions
|
@ -326,6 +326,13 @@ public interface Signal extends DBusInterface {
|
|||
}
|
||||
}
|
||||
|
||||
class DeviceNotFound extends DBusExecutionException {
|
||||
|
||||
public DeviceNotFound(final String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
class GroupNotFound extends DBusExecutionException {
|
||||
|
||||
public GroupNotFound(final String message) {
|
||||
|
|
|
@ -111,7 +111,11 @@ public class DbusSignalImpl implements Signal {
|
|||
@Override
|
||||
public DBusPath getDevice(long deviceId) {
|
||||
updateDevices();
|
||||
return new DBusPath(getDeviceObjectPath(objectPath, deviceId));
|
||||
final var deviceOptional = devices.stream().filter(g -> g.getId().equals(deviceId)).findFirst();
|
||||
if (deviceOptional.isEmpty()) {
|
||||
throw new Error.DeviceNotFound("Device not found");
|
||||
}
|
||||
return deviceOptional.get().getObjectPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue