Print more detailed error message when registering with non-normalized number

Fixes #958
This commit is contained in:
AsamK 2022-05-22 22:01:11 +02:00
parent cf07512d24
commit 995eaa6e7c
7 changed files with 35 additions and 4 deletions

View file

@ -12,6 +12,7 @@ import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.output.JsonWriter;
import java.io.IOException;
@ -76,6 +77,8 @@ public class RegisterCommand implements RegistrationCommand, JsonRpcRegistration
message = "Invalid captcha given.";
}
throw new UserErrorException(message);
} catch (NonNormalizedPhoneNumberException e) {
throw new UserErrorException("Failed to register: " + e.getMessage(), e);
} catch (IOException e) {
throw new IOErrorException("Request verify error: " + e.getMessage(), e);
}

View file

@ -9,6 +9,7 @@ import org.asamk.signal.manager.ProvisioningManager;
import org.asamk.signal.manager.RegistrationManager;
import org.asamk.signal.manager.api.CaptchaRequiredException;
import org.asamk.signal.manager.api.IncorrectPinException;
import org.asamk.signal.manager.api.NonNormalizedPhoneNumberException;
import org.asamk.signal.manager.api.PinLockedException;
import org.asamk.signal.manager.api.UserAlreadyExistsException;
import org.freedesktop.dbus.DBusPath;
@ -61,6 +62,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 (NonNormalizedPhoneNumberException e) {
throw new Error.InvalidNumber(e.getMessage());
} catch (OverlappingFileLockException e) {
throw new SignalControl.Error.Failure("Account is already in use");
} catch (IOException e) {