mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Show better error message when using addDevice on a linked device
This commit is contained in:
parent
3d13c69e41
commit
6d23eb3bf6
4 changed files with 13 additions and 7 deletions
|
@ -117,7 +117,7 @@ public interface Manager extends Closeable {
|
|||
|
||||
void removeLinkedDevices(int deviceId) throws IOException;
|
||||
|
||||
void addDeviceLink(DeviceLinkUrl linkUri) throws IOException, InvalidDeviceLinkException;
|
||||
void addDeviceLink(DeviceLinkUrl linkUri) throws IOException, InvalidDeviceLinkException, NotPrimaryDeviceException;
|
||||
|
||||
void setRegistrationLockPin(Optional<String> pin) throws IOException, NotPrimaryDeviceException;
|
||||
|
||||
|
|
|
@ -362,7 +362,10 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addDeviceLink(DeviceLinkUrl linkUrl) throws IOException, InvalidDeviceLinkException {
|
||||
public void addDeviceLink(DeviceLinkUrl linkUrl) throws IOException, InvalidDeviceLinkException, NotPrimaryDeviceException {
|
||||
if (!account.isPrimaryDevice()) {
|
||||
throw new NotPrimaryDeviceException();
|
||||
}
|
||||
context.getAccountHelper().addDevice(linkUrl);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.asamk.signal.commands.exceptions.UserErrorException;
|
|||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.DeviceLinkUrl;
|
||||
import org.asamk.signal.manager.api.InvalidDeviceLinkException;
|
||||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -49,11 +50,13 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
|
|||
var deviceLinkUrl = DeviceLinkUrl.parseDeviceLinkUri(linkUri);
|
||||
m.addDeviceLink(deviceLinkUrl);
|
||||
} catch (IOException e) {
|
||||
logger.error("Add device link failed", e);
|
||||
logger.error("Add device link failed: {}", e.getMessage());
|
||||
throw new IOErrorException("Add device link failed", e);
|
||||
} catch (InvalidDeviceLinkException e) {
|
||||
logger.error("Add device link failed", e);
|
||||
throw new UserErrorException("Add device link failed.", e);
|
||||
logger.error("Invalid device link");
|
||||
throw new UserErrorException("Invalid device link", e);
|
||||
} catch (NotPrimaryDeviceException e) {
|
||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ public class AddStickerPackCommand implements JsonRpcLocalCommand {
|
|||
var stickerPackUrl = StickerPackUrl.fromUri(stickerUri);
|
||||
m.installStickerPack(stickerPackUrl);
|
||||
} catch (IOException e) {
|
||||
logger.error("Install sticker pack failed", e);
|
||||
logger.error("Install sticker pack failed: {}", e.getMessage());
|
||||
throw new IOErrorException("Install sticker pack failed", e);
|
||||
} catch (StickerPackUrl.InvalidStickerPackLinkException e) {
|
||||
logger.error("Invalid sticker pack link", e);
|
||||
logger.error("Invalid sticker pack link");
|
||||
throw new UserErrorException("Invalid sticker pack link", e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue