mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-26 10:34:23 +01:00
Extract AccountHelper
This commit is contained in:
@@ -5,7 +5,9 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -31,6 +33,8 @@ public class RemovePinCommand implements JsonRpcLocalCommand {
|
||||
m.setRegistrationLockPin(Optional.empty());
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("Remove pin error: " + e.getMessage(), e);
|
||||
} catch (NotMasterDeviceException e) {
|
||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -34,6 +36,8 @@ public class SetPinCommand implements JsonRpcLocalCommand {
|
||||
m.setRegistrationLockPin(Optional.of(registrationLockPin));
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("Set pin error: " + e.getMessage(), e);
|
||||
} catch (NotMasterDeviceException e) {
|
||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,6 +669,8 @@ public class DbusSignalImpl implements Signal {
|
||||
m.setRegistrationLockPin(Optional.empty());
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure("Remove pin error: " + e.getMessage());
|
||||
} catch (NotMasterDeviceException e) {
|
||||
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,6 +680,8 @@ public class DbusSignalImpl implements Signal {
|
||||
m.setRegistrationLockPin(Optional.of(registrationLockPin));
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure("Set pin error: " + e.getMessage());
|
||||
} catch (NotMasterDeviceException e) {
|
||||
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user