2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Error handling changed, 'auto' keyword used for MTP types.

All errors that lead to MTP request resending by default
error handler now can be handled differently. For example
inline bot requests are not being resent on 5XX error codes.
+ extensive use of auto keyword in MTP types handling.
This commit is contained in:
John Preston
2016-04-08 14:44:35 +04:00
parent 35d5089f48
commit 8e89486fbc
41 changed files with 587 additions and 535 deletions

View File

@@ -252,7 +252,7 @@ void IntroSignup::nameSubmitDone(const MTPauth_Authorization &result) {
stopCheck();
first.setDisabled(false);
last.setDisabled(false);
const MTPDauth_authorization &d(result.c_auth_authorization());
const auto &d(result.c_auth_authorization());
if (d.vuser.type() != mtpc_user || !d.vuser.c_user().is_self()) { // wtf?
showError(lang(lng_server_error));
return;
@@ -261,11 +261,27 @@ void IntroSignup::nameSubmitDone(const MTPauth_Authorization &result) {
}
bool IntroSignup::nameSubmitFail(const RPCError &error) {
if (MTP::isFloodError(error)) {
stopCheck();
first.setDisabled(false);
last.setDisabled(false);
showError(lang(lng_flood_error));
if (_invertOrder) {
first.setFocus();
} else {
last.setFocus();
}
return true;
}
if (MTP::isDefaultHandledError(error)) return false;
stopCheck();
first.setDisabled(false);
last.setDisabled(false);
const QString &err = error.type();
if (err == "PHONE_NUMBER_INVALID" || err == "PHONE_CODE_EXPIRED" || err == "PHONE_CODE_EMPTY" || err == "PHONE_CODE_INVALID" || err == "PHONE_NUMBER_OCCUPIED") {
if (err == qstr("PHONE_NUMBER_INVALID") || err == qstr("PHONE_CODE_EXPIRED") ||
err == qstr("PHONE_CODE_EMPTY") || err == qstr("PHONE_CODE_INVALID") ||
err == qstr("PHONE_NUMBER_OCCUPIED")) {
intro()->onBack();
return true;
} else if (err == "FIRSTNAME_INVALID") {
@@ -276,14 +292,6 @@ bool IntroSignup::nameSubmitFail(const RPCError &error) {
showError(lang(lng_bad_name));
last.setFocus();
return true;
} else if (mtpIsFlood(error)) {
showError(lang(lng_flood_error));
if (_invertOrder) {
first.setFocus();
} else {
last.setFocus();
}
return true;
}
if (cDebug()) { // internal server error
showError(err + ": " + error.description());