Improve error message if captcha is rejected by server

Fixes #1328
This commit is contained in:
AsamK 2024-02-26 22:13:57 +01:00
parent e77d9e3d60
commit 189b21dbde
5 changed files with 40 additions and 4 deletions

View file

@ -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.api.CaptchaRejectedException;
import org.asamk.signal.output.OutputWriter;
import java.io.IOException;
@ -38,6 +40,9 @@ public class SubmitRateLimitChallengeCommand implements JsonRpcLocalCommand {
m.submitRateLimitRecaptchaChallenge(challenge, captcha);
} catch (IOException e) {
throw new IOErrorException("Submit challenge error: " + e.getMessage(), e);
} catch (CaptchaRejectedException e) {
throw new UserErrorException(
"Captcha rejected, it may be outdated, already used or solved from a different IP address.");
}
}
}

View file

@ -4,6 +4,7 @@ import org.asamk.Signal;
import org.asamk.signal.BaseConfig;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.AttachmentInvalidException;
import org.asamk.signal.manager.api.CaptchaRejectedException;
import org.asamk.signal.manager.api.DeviceLinkUrl;
import org.asamk.signal.manager.api.GroupId;
import org.asamk.signal.manager.api.GroupInviteLinkUrl;
@ -159,8 +160,10 @@ public class DbusSignalImpl implements Signal, AutoCloseable {
m.submitRateLimitRecaptchaChallenge(challenge, captcha);
} catch (IOException e) {
throw new Error.Failure("Submit challenge error: " + e.getMessage());
} catch (CaptchaRejectedException e) {
throw new Error.Failure(
"Captcha rejected, it may be outdated, already used or solved from a different IP address.");
}
}
@Override