mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Improve error message when an account is already in use
This commit is contained in:
parent
c8b9ab1911
commit
6c1013b024
2 changed files with 9 additions and 0 deletions
|
@ -15,6 +15,7 @@ import org.freedesktop.dbus.DBusPath;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.channels.OverlappingFileLockException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -60,6 +61,8 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
} catch (CaptchaRequiredException e) {
|
||||
String message = captcha == null ? "Captcha required for verification." : "Invalid captcha given.";
|
||||
throw new SignalControl.Error.RequiresCaptcha(message);
|
||||
} catch (OverlappingFileLockException e) {
|
||||
throw new SignalControl.Error.Failure("Account is already in use");
|
||||
} catch (IOException e) {
|
||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
}
|
||||
|
@ -76,6 +79,8 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
) throws Error.Failure, Error.InvalidNumber {
|
||||
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
|
||||
registrationManager.verifyAccount(verificationCode, pin);
|
||||
} catch (OverlappingFileLockException e) {
|
||||
throw new SignalControl.Error.Failure("Account is already in use");
|
||||
} catch (IOException | PinLockedException | IncorrectPinException e) {
|
||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.OverlappingFileLockException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
@ -182,6 +183,9 @@ public class SignalJsonRpcDispatcherHandler {
|
|||
final var registrationManager = c.getNewRegistrationManager(params.get("account").asText());
|
||||
((ObjectNode) params).remove("account");
|
||||
return registrationManager;
|
||||
} catch (OverlappingFileLockException e) {
|
||||
logger.warn("Account is already in use");
|
||||
return null;
|
||||
} catch (IOException | IllegalStateException e) {
|
||||
logger.warn("Failed to load registration manager", e);
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue