Rename RPCError to MTP::Error.

This commit is contained in:
John Preston 2021-03-12 16:48:00 +04:00
parent 5794679277
commit 68b0a85369
130 changed files with 609 additions and 594 deletions

View file

@ -55,7 +55,7 @@ void AttachedStickers::request(
Ui::show( Ui::show(
Box<StickerSetBox>(strongController, setId), Box<StickerSetBox>(strongController, setId),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now))); Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
}).send(); }).send();

View file

@ -112,7 +112,7 @@ void Authorizations::reload() {
}) | ranges::to<List>; }) | ranges::to<List>;
_listChanges.fire({}); _listChanges.fire({});
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
} }
@ -123,7 +123,7 @@ void Authorizations::cancelCurrentRequest() {
void Authorizations::requestTerminate( void Authorizations::requestTerminate(
Fn<void(const MTPBool &result)> &&done, Fn<void(const MTPBool &result)> &&done,
Fn<void(const RPCError &error)> &&fail, Fn<void(const MTP::Error &error)> &&fail,
std::optional<uint64> hash) { std::optional<uint64> hash) {
const auto send = [&](auto request) { const auto send = [&](auto request) {
_api.request( _api.request(

View file

@ -30,7 +30,7 @@ public:
void cancelCurrentRequest(); void cancelCurrentRequest();
void requestTerminate( void requestTerminate(
Fn<void(const MTPBool &result)> &&done, Fn<void(const MTPBool &result)> &&done,
Fn<void(const RPCError &error)> &&fail, Fn<void(const MTP::Error &error)> &&fail,
std::optional<uint64> hash = std::nullopt); std::optional<uint64> hash = std::nullopt);
[[nodiscard]] crl::time lastReceivedTime(); [[nodiscard]] crl::time lastReceivedTime();

View file

@ -34,7 +34,7 @@ void SendBotCallbackData(
int row, int row,
int column, int column,
std::optional<MTPInputCheckPasswordSRP> password = std::nullopt, std::optional<MTPInputCheckPasswordSRP> password = std::nullopt,
Fn<void(const RPCError &)> handleError = nullptr) { Fn<void(const MTP::Error &)> handleError = nullptr) {
if (!IsServerMsgId(item->id)) { if (!IsServerMsgId(item->id)) {
return; return;
} }
@ -115,7 +115,7 @@ void SendBotCallbackData(
Ui::hideLayer(); Ui::hideLayer();
} }
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto item = owner->message(fullId); const auto item = owner->message(fullId);
if (!item) { if (!item) {
return; return;
@ -170,7 +170,7 @@ void SendBotCallbackDataWithPassword(
return; return;
} }
api->reloadPasswordState(); api->reloadPasswordState();
SendBotCallbackData(item, row, column, MTP_inputCheckPasswordEmpty(), [=](const RPCError &error) { SendBotCallbackData(item, row, column, MTP_inputCheckPasswordEmpty(), [=](const MTP::Error &error) {
auto box = PrePasswordErrorBox( auto box = PrePasswordErrorBox(
error, error,
session, session,
@ -212,7 +212,7 @@ void SendBotCallbackDataWithPassword(
return; return;
} }
if (const auto item = owner->message(fullId)) { if (const auto item = owner->message(fullId)) {
SendBotCallbackData(item, row, column, result.result, [=](const RPCError &error) { SendBotCallbackData(item, row, column, result.result, [=](const MTP::Error &error) {
if (*box) { if (*box) {
(*box)->handleCustomCheckError(error); (*box)->handleCustomCheckError(error);
} }

View file

@ -75,7 +75,7 @@ void CheckChatInvite(
} }
} }
}); });
}, [=](const RPCError &error) { }, [=](const MTP::Error &error) {
if (error.code() != 400) { if (error.code() != 400) {
return; return;
} }

View file

@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "mtproto/mtproto_rpc_sender.h" #include "mtproto/mtproto_response.h"
namespace Api { namespace Api {
namespace { namespace {
@ -131,7 +131,7 @@ void EditMessageWithUploadedMedia(
item->setIsLocalUpdateMedia(false); item->setIsLocalUpdateMedia(false);
} }
}; };
const auto fail = [=](const RPCError &error) { const auto fail = [=](const MTP::Error &error) {
const auto err = error.type(); const auto err = error.type();
const auto session = &item->history()->session(); const auto session = &item->history()->session();
const auto notModified = (err == u"MESSAGE_NOT_MODIFIED"_q); const auto notModified = (err == u"MESSAGE_NOT_MODIFIED"_q);
@ -189,7 +189,7 @@ mtpRequestId EditCaption(
const TextWithEntities &caption, const TextWithEntities &caption,
SendOptions options, SendOptions options,
Fn<void(const MTPUpdates &)> done, Fn<void(const MTPUpdates &)> done,
Fn<void(const RPCError &)> fail) { Fn<void(const MTP::Error &)> fail) {
return EditMessage(item, caption, options, done, fail); return EditMessage(item, caption, options, done, fail);
} }
@ -198,7 +198,7 @@ mtpRequestId EditTextMessage(
const TextWithEntities &caption, const TextWithEntities &caption,
SendOptions options, SendOptions options,
Fn<void(const MTPUpdates &, mtpRequestId requestId)> done, Fn<void(const MTPUpdates &, mtpRequestId requestId)> done,
Fn<void(const RPCError &, mtpRequestId requestId)> fail) { Fn<void(const MTP::Error &, mtpRequestId requestId)> fail) {
const auto callback = [=]( const auto callback = [=](
const auto &result, const auto &result,
Fn<void()> applyUpdates, Fn<void()> applyUpdates,

View file

@ -8,7 +8,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once #pragma once
class HistoryItem; class HistoryItem;
class RPCError;
namespace MTP {
class Error;
} // namespace MTP
namespace Api { namespace Api {
@ -40,13 +43,13 @@ mtpRequestId EditCaption(
const TextWithEntities &caption, const TextWithEntities &caption,
SendOptions options, SendOptions options,
Fn<void(const MTPUpdates &)> done, Fn<void(const MTPUpdates &)> done,
Fn<void(const RPCError &)> fail); Fn<void(const MTP::Error &)> fail);
mtpRequestId EditTextMessage( mtpRequestId EditTextMessage(
not_null<HistoryItem*> item, not_null<HistoryItem*> item,
const TextWithEntities &caption, const TextWithEntities &caption,
SendOptions options, SendOptions options,
Fn<void(const MTPUpdates &, mtpRequestId requestId)> done, Fn<void(const MTPUpdates &, mtpRequestId requestId)> done,
Fn<void(const RPCError &, mtpRequestId requestId)> fail); Fn<void(const MTP::Error &, mtpRequestId requestId)> fail);
} // namespace Api } // namespace Api

View file

@ -33,7 +33,7 @@ void GlobalPrivacy::reload(Fn<void()> callback) {
for (const auto &callback : base::take(_callbacks)) { for (const auto &callback : base::take(_callbacks)) {
callback(); callback();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
for (const auto &callback : base::take(_callbacks)) { for (const auto &callback : base::take(_callbacks)) {
callback(); callback();
@ -86,7 +86,7 @@ void GlobalPrivacy::update(bool archiveAndMute) {
)).done([=](const MTPGlobalPrivacySettings &result) { )).done([=](const MTPGlobalPrivacySettings &result) {
_requestId = 0; _requestId = 0;
apply(result); apply(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
_archiveAndMute = archiveAndMute; _archiveAndMute = archiveAndMute;

View file

@ -110,7 +110,7 @@ void InviteLinks::performCreate(
callback(link); callback(link);
} }
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_createCallbacks.erase(peer); _createCallbacks.erase(peer);
}).send(); }).send();
} }
@ -282,7 +282,7 @@ void InviteLinks::performEdit(
prepend(peer, admin, data.vnew_invite()); prepend(peer, admin, data.vnew_invite());
} }
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_editCallbacks.erase(key); _editCallbacks.erase(key);
}).send(); }).send();
} }
@ -344,7 +344,7 @@ void InviteLinks::destroy(
.admin = admin, .admin = admin,
.was = key.link, .was = key.link,
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_deleteCallbacks.erase(key); _deleteCallbacks.erase(key);
}).send(); }).send();
} }
@ -374,7 +374,7 @@ void InviteLinks::destroyAllRevoked(
} }
} }
_allRevokedDestroyed.fire({ peer, admin }); _allRevokedDestroyed.fire({ peer, admin });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
}).send(); }).send();
} }
@ -415,7 +415,7 @@ void InviteLinks::requestMyLinks(not_null<PeerData*> peer) {
i->second.count = std::max(slice.count, int(existing.size())); i->second.count = std::max(slice.count, int(existing.size()));
} }
notify(peer); notify(peer);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_firstSliceRequests.remove(peer); _firstSliceRequests.remove(peer);
}).send(); }).send();
_firstSliceRequests.emplace(peer, requestId); _firstSliceRequests.emplace(peer, requestId);
@ -493,7 +493,7 @@ void InviteLinks::requestJoinedFirstSlice(LinkKey key) {
_firstJoinedRequests.remove(key); _firstJoinedRequests.remove(key);
_firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result); _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result);
_joinedFirstSliceLoaded.fire_copy(key); _joinedFirstSliceLoaded.fire_copy(key);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_firstJoinedRequests.remove(key); _firstJoinedRequests.remove(key);
}).send(); }).send();
_firstJoinedRequests.emplace(key, requestId); _firstJoinedRequests.emplace(key, requestId);
@ -653,7 +653,7 @@ void InviteLinks::requestMoreLinks(
MTP_int(kPerPage) MTP_int(kPerPage)
)).done([=](const MTPmessages_ExportedChatInvites &result) { )).done([=](const MTPmessages_ExportedChatInvites &result) {
done(parseSlice(peer, result)); done(parseSlice(peer, result));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
done(Links()); done(Links());
}).send(); }).send();
} }

View file

@ -25,7 +25,7 @@ void SelfDestruct::reload() {
result.match([&](const MTPDaccountDaysTTL &data) { result.match([&](const MTPDaccountDaysTTL &data) {
_days = data.vdays().v; _days = data.vdays().v;
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
} }
@ -42,7 +42,7 @@ void SelfDestruct::update(int days) {
MTP_accountDaysTTL(MTP_int(days)) MTP_accountDaysTTL(MTP_int(days))
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
_requestId = 0; _requestId = 0;
}).fail([=](const RPCError &result) { }).fail([=](const MTP::Error &result) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
_days = days; _days = days;

View file

@ -150,7 +150,7 @@ void SendExistingMedia(
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
api->applyUpdates(result, randomId); api->applyUpdates(result, randomId);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.code() == 400 if (error.code() == 400
&& error.type().startsWith(qstr("FILE_REFERENCE_"))) { && error.type().startsWith(qstr("FILE_REFERENCE_"))) {
api->refreshFileReference(origin, [=](const auto &result) { api->refreshFileReference(origin, [=](const auto &result) {
@ -324,7 +324,7 @@ bool SendDice(Api::MessageToSend &message) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
api->applyUpdates(result, randomId); api->applyUpdates(result, randomId);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
api->sendMessageFail(error, peer, randomId, newId); api->sendMessageFail(error, peer, randomId, newId);
finish(); finish();
}).afterRequest(history->sendRequestId }).afterRequest(history->sendRequestId

View file

@ -36,7 +36,7 @@ void SensitiveContent::reload() {
_enabled = data.is_sensitive_enabled(); _enabled = data.is_sensitive_enabled();
_canChange = data.is_sensitive_can_change(); _canChange = data.is_sensitive_can_change();
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
} }
@ -63,7 +63,7 @@ void SensitiveContent::update(bool enabled) {
MTP_flags(enabled ? Flag::f_sensitive_enabled : Flag(0)) MTP_flags(enabled ? Flag::f_sensitive_enabled : Flag(0))
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
_requestId = 0; _requestId = 0;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
_enabled = enabled; _enabled = enabled;

View file

@ -117,7 +117,7 @@ std::optional<HistoryItem*> SingleMessageSearch::performLookupByChannel(
} else { } else {
fail(); fail();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
fail(); fail();
}).send(); }).send();
@ -154,7 +154,7 @@ std::optional<HistoryItem*> SingleMessageSearch::performLookupById(
fail(); fail();
} }
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
fail(); fail();
}).send(); }).send();
@ -198,7 +198,7 @@ std::optional<HistoryItem*> SingleMessageSearch::performLookupByUsername(
fail(); fail();
} }
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
fail(); fail();
}).send(); }).send();

View file

@ -33,7 +33,7 @@ void ToggleExistingMedia(
if (mtpIsTrue(result)) { if (mtpIsTrue(result)) {
done(); done();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.code() == 400 if (error.code() == 400
&& error.type().startsWith(u"FILE_REFERENCE_"_q)) { && error.type().startsWith(u"FILE_REFERENCE_"_q)) {
auto refreshed = [=](const Data::UpdatedFileReferences &d) { auto refreshed = [=](const Data::UpdatedFileReferences &d) {

View file

@ -398,7 +398,7 @@ void Updates::feedChannelDifference(
void Updates::channelDifferenceFail( void Updates::channelDifferenceFail(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
const RPCError &error) { const MTP::Error &error) {
LOG(("RPC Error in getChannelDifference: %1 %2: %3" LOG(("RPC Error in getChannelDifference: %1 %2: %3"
).arg(error.code() ).arg(error.code()
).arg(error.type() ).arg(error.type()
@ -556,7 +556,7 @@ void Updates::feedDifference(
feedUpdateVector(other, true); feedUpdateVector(other, true);
} }
void Updates::differenceFail(const RPCError &error) { void Updates::differenceFail(const MTP::Error &error) {
LOG(("RPC Error in getDifference: %1 %2: %3" LOG(("RPC Error in getDifference: %1 %2: %3"
).arg(error.code() ).arg(error.code()
).arg(error.type() ).arg(error.type()
@ -643,7 +643,7 @@ void Updates::getDifference() {
MTP_int(_updatesQts) MTP_int(_updatesQts)
)).done([=](const MTPupdates_Difference &result) { )).done([=](const MTPupdates_Difference &result) {
differenceDone(result); differenceDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
differenceFail(error); differenceFail(error);
}).send(); }).send();
} }
@ -678,7 +678,7 @@ void Updates::getChannelDifference(
MTP_int(kChannelGetDifferenceLimit) MTP_int(kChannelGetDifferenceLimit)
)).done([=](const MTPupdates_ChannelDifference &result) { )).done([=](const MTPupdates_ChannelDifference &result) {
channelDifferenceDone(channel, result); channelDifferenceDone(channel, result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
channelDifferenceFail(channel, error); channelDifferenceFail(channel, error);
}).send(); }).send();
} }
@ -742,7 +742,7 @@ void Updates::channelRangeDifferenceSend(
)).done([=](const MTPupdates_ChannelDifference &result) { )).done([=](const MTPupdates_ChannelDifference &result) {
_rangeDifferenceRequests.remove(channel); _rangeDifferenceRequests.remove(channel);
channelRangeDifferenceDone(channel, range, result); channelRangeDifferenceDone(channel, range, result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_rangeDifferenceRequests.remove(channel); _rangeDifferenceRequests.remove(channel);
}).send(); }).send();
_rangeDifferenceRequests.emplace(channel, requestId); _rangeDifferenceRequests.emplace(channel, requestId);
@ -862,7 +862,7 @@ void Updates::updateOnline(bool gotOtherOffline) {
MTP_bool(!isOnline) MTP_bool(!isOnline)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
Core::App().quitPreventFinished(); Core::App().quitPreventFinished();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
Core::App().quitPreventFinished(); Core::App().quitPreventFinished();
}).send(); }).send();
} }

View file

@ -10,10 +10,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_pts_waiter.h" #include "data/data_pts_waiter.h"
#include "base/timer.h" #include "base/timer.h"
class RPCError;
class ApiWrap; class ApiWrap;
class History; class History;
namespace MTP {
class Error;
} // namespace MTP
namespace Main { namespace Main {
class Session; class Session;
} // namespace Main } // namespace Main
@ -89,7 +92,7 @@ private:
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
ChannelDifferenceRequest from = ChannelDifferenceRequest::Unknown); ChannelDifferenceRequest from = ChannelDifferenceRequest::Unknown);
void differenceDone(const MTPupdates_Difference &result); void differenceDone(const MTPupdates_Difference &result);
void differenceFail(const RPCError &error); void differenceFail(const MTP::Error &error);
void feedDifference( void feedDifference(
const MTPVector<MTPUser> &users, const MTPVector<MTPUser> &users,
const MTPVector<MTPChat> &chats, const MTPVector<MTPChat> &chats,
@ -102,7 +105,7 @@ private:
const MTPupdates_ChannelDifference &diff); const MTPupdates_ChannelDifference &diff);
void channelDifferenceFail( void channelDifferenceFail(
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
const RPCError &error); const MTP::Error &error);
void failDifferenceStartTimerFor(ChannelData *channel); void failDifferenceStartTimerFor(ChannelData *channel);
void feedChannelDifference(const MTPDupdates_channelDifference &data); void feedChannelDifference(const MTPDupdates_channelDifference &data);

View file

@ -279,7 +279,7 @@ void ApiWrap::refreshTopPromotion() {
)).done([=](const MTPhelp_PromoData &result) { )).done([=](const MTPhelp_PromoData &result) {
_topPromotionRequestId = 0; _topPromotionRequestId = 0;
topPromotionDone(result); topPromotionDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_topPromotionRequestId = 0; _topPromotionRequestId = 0;
const auto now = base::unixtime::now(); const auto now = base::unixtime::now();
const auto next = _topPromotionNextRequestTime = now const auto next = _topPromotionNextRequestTime = now
@ -329,7 +329,7 @@ void ApiWrap::requestDeepLinkInfo(
if (result.type() == mtpc_help_deepLinkInfo) { if (result.type() == mtpc_help_deepLinkInfo) {
callback(result.c_help_deepLinkInfo()); callback(result.c_help_deepLinkInfo());
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_deepLinkInfoRequestId = 0; _deepLinkInfoRequestId = 0;
}).send(); }).send();
} }
@ -376,7 +376,7 @@ void ApiWrap::requestTermsUpdate() {
} break; } break;
default: Unexpected("Type in requestTermsUpdate()."); default: Unexpected("Type in requestTermsUpdate().");
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_termsUpdateRequestId = 0; _termsUpdateRequestId = 0;
_termsUpdateSendAt = crl::now() + kTermsUpdateTimeoutMin; _termsUpdateSendAt = crl::now() + kTermsUpdateTimeoutMin;
requestTermsUpdate(); requestTermsUpdate();
@ -394,7 +394,7 @@ void ApiWrap::acceptTerms(bytes::const_span id) {
void ApiWrap::checkChatInvite( void ApiWrap::checkChatInvite(
const QString &hash, const QString &hash,
FnMut<void(const MTPChatInvite &)> done, FnMut<void(const MTPChatInvite &)> done,
Fn<void(const RPCError &)> fail) { Fn<void(const MTP::Error &)> fail) {
request(base::take(_checkInviteRequestId)).cancel(); request(base::take(_checkInviteRequestId)).cancel();
_checkInviteRequestId = request(MTPmessages_CheckChatInvite( _checkInviteRequestId = request(MTPmessages_CheckChatInvite(
MTP_string(hash) MTP_string(hash)
@ -436,7 +436,7 @@ void ApiWrap::importChatInvite(const QString &hash) {
LOG(("API Error: unexpected update cons %1 " LOG(("API Error: unexpected update cons %1 "
"(ApiWrap::importChatInvite)").arg(result.type())); "(ApiWrap::importChatInvite)").arg(result.type()));
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("CHANNELS_TOO_MUCH")) { if (type == qstr("CHANNELS_TOO_MUCH")) {
Ui::show(Box<InformBox>(tr::lng_join_channel_error(tr::now))); Ui::show(Box<InformBox>(tr::lng_join_channel_error(tr::now)));
@ -501,14 +501,14 @@ void ApiWrap::toggleHistoryArchived(
if (isPinned) { if (isPinned) {
_session->data().notifyPinnedDialogsOrderUpdated(); _session->data().notifyPinnedDialogsOrderUpdated();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_historyArchivedRequests.remove(history); _historyArchivedRequests.remove(history);
}).send(); }).send();
_historyArchivedRequests.emplace(history, requestId, callback); _historyArchivedRequests.emplace(history, requestId, callback);
} }
void ApiWrap::sendMessageFail( void ApiWrap::sendMessageFail(
const RPCError &error, const MTP::Error &error,
not_null<PeerData*> peer, not_null<PeerData*> peer,
uint64 randomId, uint64 randomId,
FullMsgId itemId) { FullMsgId itemId) {
@ -591,7 +591,7 @@ void ApiWrap::resolveMessageDatas() {
MTP_vector<MTPInputMessage>(ids) MTP_vector<MTPInputMessage>(ids)
)).done([this](const MTPmessages_Messages &result, mtpRequestId requestId) { )).done([this](const MTPmessages_Messages &result, mtpRequestId requestId) {
gotMessageDatas(nullptr, result, requestId); gotMessageDatas(nullptr, result, requestId);
}).fail([this](const RPCError &error, mtpRequestId requestId) { }).fail([this](const MTP::Error &error, mtpRequestId requestId) {
finalizeMessageDataRequest(nullptr, requestId); finalizeMessageDataRequest(nullptr, requestId);
}).afterDelay(kSmallDelayMs).send(); }).afterDelay(kSmallDelayMs).send();
for (auto &request : _messageDataRequests) { for (auto &request : _messageDataRequests) {
@ -612,7 +612,7 @@ void ApiWrap::resolveMessageDatas() {
MTP_vector<MTPInputMessage>(ids) MTP_vector<MTPInputMessage>(ids)
)).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) { )).done([=](const MTPmessages_Messages &result, mtpRequestId requestId) {
gotMessageDatas(channel, result, requestId); gotMessageDatas(channel, result, requestId);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
finalizeMessageDataRequest(channel, requestId); finalizeMessageDataRequest(channel, requestId);
}).afterDelay(kSmallDelayMs).send(); }).afterDelay(kSmallDelayMs).send();
@ -782,7 +782,7 @@ void ApiWrap::requestContacts() {
} }
} }
_session->data().contactsLoaded() = true; _session->data().contactsLoaded() = true;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_contactsRequestId = 0; _contactsRequestId = 0;
}).send(); }).send();
} }
@ -856,7 +856,7 @@ void ApiWrap::requestMoreDialogs(Data::Folder *folder) {
} }
requestMoreDialogsIfNeeded(); requestMoreDialogsIfNeeded();
_session->data().chatsListChanged(folder); _session->data().chatsListChanged(folder);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
dialogsLoadState(folder)->requestId = 0; dialogsLoadState(folder)->requestId = 0;
}).send(); }).send();
@ -1001,7 +1001,7 @@ void ApiWrap::requestPinnedDialogs(Data::Folder *folder) {
_session->data().chatsListChanged(folder); _session->data().chatsListChanged(folder);
_session->data().notifyPinnedDialogsOrderUpdated(); _session->data().notifyPinnedDialogsOrderUpdated();
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finalize(); finalize();
}).send(); }).send();
} }
@ -1029,7 +1029,7 @@ rpl::producer<bool> ApiWrap::dialogsLoadBlockedByDate() const {
void ApiWrap::requestWallPaper( void ApiWrap::requestWallPaper(
const QString &slug, const QString &slug,
Fn<void(const Data::WallPaper &)> done, Fn<void(const Data::WallPaper &)> done,
Fn<void(const RPCError &)> fail) { Fn<void(const MTP::Error &)> fail) {
if (_wallPaperSlug != slug) { if (_wallPaperSlug != slug) {
_wallPaperSlug = slug; _wallPaperSlug = slug;
if (_wallPaperRequestId) { if (_wallPaperRequestId) {
@ -1051,9 +1051,9 @@ void ApiWrap::requestWallPaper(
done(*paper); done(*paper);
} }
} else if (const auto fail = base::take(_wallPaperFail)) { } else if (const auto fail = base::take(_wallPaperFail)) {
fail(RPCError::Local("BAD_DOCUMENT", "In a wallpaper.")); fail(MTP::Error::Local("BAD_DOCUMENT", "In a wallpaper."));
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_wallPaperRequestId = 0; _wallPaperRequestId = 0;
_wallPaperSlug = QString(); _wallPaperSlug = QString();
if (const auto fail = base::take(_wallPaperFail)) { if (const auto fail = base::take(_wallPaperFail)) {
@ -1068,7 +1068,7 @@ void ApiWrap::requestFullPeer(not_null<PeerData*> peer) {
} }
const auto requestId = [&] { const auto requestId = [&] {
const auto failHandler = [=](const RPCError &error) { const auto failHandler = [=](const MTP::Error &error) {
_fullPeerRequests.remove(peer); _fullPeerRequests.remove(peer);
migrateFail(peer, error); migrateFail(peer, error);
}; };
@ -1180,7 +1180,7 @@ void ApiWrap::requestPeer(not_null<PeerData*> peer) {
} }
const auto requestId = [&] { const auto requestId = [&] {
const auto failHandler = [=](const RPCError &error) { const auto failHandler = [=](const MTP::Error &error) {
_peerRequests.remove(peer); _peerRequests.remove(peer);
}; };
const auto chatHandler = [=](const MTPmessages_Chats &result) { const auto chatHandler = [=](const MTPmessages_Chats &result) {
@ -1223,7 +1223,7 @@ void ApiWrap::requestPeerSettings(not_null<PeerData*> peer) {
return data.vflags().v; return data.vflags().v;
})); }));
_requestedPeerSettings.erase(peer); _requestedPeerSettings.erase(peer);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestedPeerSettings.erase(peer); _requestedPeerSettings.erase(peer);
}).send(); }).send();
} }
@ -1231,7 +1231,7 @@ void ApiWrap::requestPeerSettings(not_null<PeerData*> peer) {
void ApiWrap::migrateChat( void ApiWrap::migrateChat(
not_null<ChatData*> chat, not_null<ChatData*> chat,
FnMut<void(not_null<ChannelData*>)> done, FnMut<void(not_null<ChannelData*>)> done,
Fn<void(const RPCError &)> fail) { Fn<void(const MTP::Error &)> fail) {
const auto callback = [&] { const auto callback = [&] {
return MigrateCallbacks{ std::move(done), std::move(fail) }; return MigrateCallbacks{ std::move(done), std::move(fail) };
}; };
@ -1252,7 +1252,7 @@ void ApiWrap::migrateChat(
crl::on_main([=] { crl::on_main([=] {
migrateFail( migrateFail(
chat, chat,
RPCError::Local( MTP::Error::Local(
"BAD_MIGRATION", "BAD_MIGRATION",
"Chat is already deactivated")); "Chat is already deactivated"));
}); });
@ -1261,7 +1261,7 @@ void ApiWrap::migrateChat(
crl::on_main([=] { crl::on_main([=] {
migrateFail( migrateFail(
chat, chat,
RPCError::Local( MTP::Error::Local(
"BAD_MIGRATION", "BAD_MIGRATION",
"Current user is not the creator of that chat")); "Current user is not the creator of that chat"));
}); });
@ -1282,9 +1282,9 @@ void ApiWrap::migrateChat(
} else { } else {
migrateFail( migrateFail(
chat, chat,
RPCError::Local("MIGRATION_FAIL", "No channel")); MTP::Error::Local("MIGRATION_FAIL", "No channel"));
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
migrateFail(chat, error); migrateFail(chat, error);
}).send(); }).send();
} }
@ -1302,7 +1302,7 @@ void ApiWrap::migrateDone(
} }
} }
void ApiWrap::migrateFail(not_null<PeerData*> peer, const RPCError &error) { void ApiWrap::migrateFail(not_null<PeerData*> peer, const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("CHANNELS_TOO_MUCH")) { if (type == qstr("CHANNELS_TOO_MUCH")) {
Ui::show(Box<InformBox>(tr::lng_migrate_error(tr::now))); Ui::show(Box<InformBox>(tr::lng_migrate_error(tr::now)));
@ -1446,7 +1446,7 @@ void ApiWrap::requestLastParticipants(not_null<ChannelData*> channel) {
availableCount, availableCount,
list); list);
}); });
}).fail([this, channel](const RPCError &error) { }).fail([this, channel](const MTP::Error &error) {
_participantsRequests.remove(channel); _participantsRequests.remove(channel);
}).send(); }).send();
@ -1476,7 +1476,7 @@ void ApiWrap::requestBots(not_null<ChannelData*> channel) {
availableCount, availableCount,
list); list);
}); });
}).fail([this, channel](const RPCError &error) { }).fail([this, channel](const MTP::Error &error) {
_botsRequests.remove(channel); _botsRequests.remove(channel);
}).send(); }).send();
@ -1503,7 +1503,7 @@ void ApiWrap::requestAdmins(not_null<ChannelData*> channel) {
}, [&](const MTPDchannels_channelParticipantsNotModified &) { }, [&](const MTPDchannels_channelParticipantsNotModified &) {
LOG(("API Error: channels.channelParticipantsNotModified received!")); LOG(("API Error: channels.channelParticipantsNotModified received!"));
}); });
}).fail([this, channel](const RPCError &error) { }).fail([this, channel](const MTP::Error &error) {
_adminsRequests.remove(channel); _adminsRequests.remove(channel);
}).send(); }).send();
@ -1687,7 +1687,7 @@ void ApiWrap::requestSelfParticipant(not_null<ChannelData*> channel) {
finalize(-1, 0); finalize(-1, 0);
}); });
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_selfParticipantRequests.erase(channel); _selfParticipantRequests.erase(channel);
if (error.type() == qstr("CHANNEL_PRIVATE")) { if (error.type() == qstr("CHANNEL_PRIVATE")) {
channel->privateErrorReceived(); channel->privateErrorReceived();
@ -1725,7 +1725,7 @@ void ApiWrap::kickParticipant(
_kickRequests.remove(KickRequest(channel, user)); _kickRequests.remove(KickRequest(channel, user));
channel->applyEditBanned(user, currentRights, rights); channel->applyEditBanned(user, currentRights, rights);
}).fail([this, kick](const RPCError &error) { }).fail([this, kick](const MTP::Error &error) {
_kickRequests.remove(kick); _kickRequests.remove(kick);
}).send(); }).send();
@ -1753,7 +1753,7 @@ void ApiWrap::unblockParticipant(
} else { } else {
channel->updateFullForced(); channel->updateFullForced();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_kickRequests.remove(kick); _kickRequests.remove(kick);
}).send(); }).send();
@ -1818,7 +1818,7 @@ void ApiWrap::requestChannelMembersForAdd(
base::take(_channelMembersForAddRequestId); base::take(_channelMembersForAddRequestId);
base::take(_channelMembersForAdd); base::take(_channelMembersForAdd);
base::take(_channelMembersForAddCallback)(result); base::take(_channelMembersForAddCallback)(result);
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
base::take(_channelMembersForAddRequestId); base::take(_channelMembersForAddRequestId);
base::take(_channelMembersForAdd); base::take(_channelMembersForAdd);
base::take(_channelMembersForAddCallback); base::take(_channelMembersForAddCallback);
@ -1839,7 +1839,7 @@ void ApiWrap::requestStickerSets() {
auto waitMs = (j == e) ? 0 : kSmallDelayMs; auto waitMs = (j == e) ? 0 : kSmallDelayMs;
i.value().second = request(MTPmessages_GetStickerSet(MTP_inputStickerSetID(MTP_long(i.key()), MTP_long(i.value().first)))).done([this, setId = i.key()](const MTPmessages_StickerSet &result) { i.value().second = request(MTPmessages_GetStickerSet(MTP_inputStickerSetID(MTP_long(i.key()), MTP_long(i.value().first)))).done([this, setId = i.key()](const MTPmessages_StickerSet &result) {
gotStickerSet(setId, result); gotStickerSet(setId, result);
}).fail([this, setId = i.key()](const RPCError &error) { }).fail([this, setId = i.key()](const MTP::Error &error) {
_stickerSetRequests.remove(setId); _stickerSetRequests.remove(setId);
}).afterDelay(waitMs).send(); }).afterDelay(waitMs).send();
} }
@ -1876,7 +1876,7 @@ void ApiWrap::saveStickerSets(
MTP_flags(0) MTP_flags(0)
)).done([this](const MTPBool &result) { )).done([this](const MTPBool &result) {
_stickersClearRecentRequestId = 0; _stickersClearRecentRequestId = 0;
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
_stickersClearRecentRequestId = 0; _stickersClearRecentRequestId = 0;
}).send(); }).send();
continue; continue;
@ -1898,7 +1898,7 @@ void ApiWrap::saveStickerSets(
auto requestId = request(MTPmessages_UninstallStickerSet(setId)).done([this](const MTPBool &result, mtpRequestId requestId) { auto requestId = request(MTPmessages_UninstallStickerSet(setId)).done([this](const MTPBool &result, mtpRequestId requestId) {
stickerSetDisenabled(requestId); stickerSetDisenabled(requestId);
}).fail([this](const RPCError &error, mtpRequestId requestId) { }).fail([this](const MTP::Error &error, mtpRequestId requestId) {
stickerSetDisenabled(requestId); stickerSetDisenabled(requestId);
}).afterDelay(kSmallDelayMs).send(); }).afterDelay(kSmallDelayMs).send();
@ -1944,7 +1944,7 @@ void ApiWrap::saveStickerSets(
mtpRequestId requestId) { mtpRequestId requestId) {
stickerSetDisenabled(requestId); stickerSetDisenabled(requestId);
}).fail([=]( }).fail([=](
const RPCError &error, const MTP::Error &error,
mtpRequestId requestId) { mtpRequestId requestId) {
stickerSetDisenabled(requestId); stickerSetDisenabled(requestId);
}).afterDelay(kSmallDelayMs).send(); }).afterDelay(kSmallDelayMs).send();
@ -2006,7 +2006,7 @@ void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_channelAmInRequests.remove(channel); _channelAmInRequests.remove(channel);
applyUpdates(result); applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.type() == qstr("CHANNEL_PRIVATE") if (error.type() == qstr("CHANNEL_PRIVATE")
&& channel->invitePeekExpires()) { && channel->invitePeekExpires()) {
channel->privateErrorReceived(); channel->privateErrorReceived();
@ -2039,7 +2039,7 @@ void ApiWrap::leaveChannel(not_null<ChannelData*> channel) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_channelAmInRequests.remove(channel); _channelAmInRequests.remove(channel);
applyUpdates(result); applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_channelAmInRequests.remove(channel); _channelAmInRequests.remove(channel);
}).send(); }).send();
@ -2065,7 +2065,7 @@ void ApiWrap::blockPeer(not_null<PeerData*> peer) {
++_blockedPeersSlice->total; ++_blockedPeersSlice->total;
_blockedPeersChanges.fire_copy(*_blockedPeersSlice); _blockedPeersChanges.fire_copy(*_blockedPeersSlice);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_blockRequests.erase(peer); _blockRequests.erase(peer);
}).send(); }).send();
@ -2103,7 +2103,7 @@ void ApiWrap::unblockPeer(not_null<PeerData*> peer, Fn<void()> onDone) {
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_blockRequests.erase(peer); _blockRequests.erase(peer);
}).send(); }).send();
_blockRequests.emplace(peer, requestId); _blockRequests.emplace(peer, requestId);
@ -2143,7 +2143,7 @@ void ApiWrap::requestNotifySettings(const MTPInputNotifyPeer &peer) {
)).done([=](const MTPPeerNotifySettings &result) { )).done([=](const MTPPeerNotifySettings &result) {
applyNotifySettings(peer, result); applyNotifySettings(peer, result);
_notifySettingRequests.erase(key); _notifySettingRequests.erase(key);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
applyNotifySettings( applyNotifySettings(
peer, peer,
MTP_peerNotifySettings( MTP_peerNotifySettings(
@ -2203,7 +2203,7 @@ void ApiWrap::savePrivacy(
handlePrivacyChange(*key, data.vrules()); handlePrivacyChange(*key, data.vrules());
} }
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_privacySaveRequests.remove(keyTypeId); _privacySaveRequests.remove(keyTypeId);
}).send(); }).send();
@ -2263,7 +2263,7 @@ void ApiWrap::updatePrivacyLastSeens(const QVector<MTPPrivacyRule> &rules) {
} }
} }
} }
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
_contactsStatusesRequestId = 0; _contactsStatusesRequestId = 0;
}).send(); }).send();
} }
@ -2297,7 +2297,7 @@ void ApiWrap::deleteConversation(not_null<PeerData*> peer, bool revoke) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
applyUpdates(result); applyUpdates(result);
deleteHistory(peer, false, revoke); deleteHistory(peer, false, revoke);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
deleteHistory(peer, false, revoke); deleteHistory(peer, false, revoke);
}).send(); }).send();
} else { } else {
@ -2472,7 +2472,7 @@ void ApiWrap::saveDraftsToCloud() {
_draftsSaveRequestIds.erase(history); _draftsSaveRequestIds.erase(history);
checkQuitPreventFinished(); checkQuitPreventFinished();
} }
}).fail([=](const RPCError &error, const MTP::Response &response) { }).fail([=](const MTP::Error &error, const MTP::Response &response) {
history->finishSavingCloudDraft( history->finishSavingCloudDraft(
UnixtimeFromMsgId(response.outerMsgId)); UnixtimeFromMsgId(response.outerMsgId));
@ -2724,7 +2724,7 @@ void ApiWrap::requestFileReference(
for (auto &handler : handlers) { for (auto &handler : handlers) {
handler(parsed); handler(parsed);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto i = _fileReferenceHandlers.find(origin); const auto i = _fileReferenceHandlers.find(origin);
Assert(i != end(_fileReferenceHandlers)); Assert(i != end(_fileReferenceHandlers));
auto handlers = std::move(i->second); auto handlers = std::move(i->second);
@ -2881,7 +2881,7 @@ void ApiWrap::stickersSaveOrder() {
MTP_vector<MTPlong>(mtpOrder) MTP_vector<MTPlong>(mtpOrder)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
_stickersReorderRequestId = 0; _stickersReorderRequestId = 0;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_stickersReorderRequestId = 0; _stickersReorderRequestId = 0;
_session->data().stickers().setLastUpdate(0); _session->data().stickers().setLastUpdate(0);
updateStickers(); updateStickers();
@ -2979,7 +2979,7 @@ void ApiWrap::requestStickers(TimeId now) {
}; };
_stickersUpdateRequest = request(MTPmessages_GetAllStickers( _stickersUpdateRequest = request(MTPmessages_GetAllStickers(
MTP_int(Api::CountStickersHash(_session, true)) MTP_int(Api::CountStickersHash(_session, true))
)).done(onDone).fail([=](const RPCError &error) { )).done(onDone).fail([=](const MTP::Error &error) {
LOG(("App Fail: Failed to get stickers!")); LOG(("App Fail: Failed to get stickers!"));
onDone(MTP_messages_allStickersNotModified()); onDone(MTP_messages_allStickersNotModified());
}).send(); }).send();
@ -3018,7 +3018,7 @@ void ApiWrap::requestRecentStickersWithHash(int32 hash) {
} return; } return;
default: Unexpected("Type in ApiWrap::recentStickersDone()"); default: Unexpected("Type in ApiWrap::recentStickersDone()");
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_session->data().stickers().setLastRecentUpdate(crl::now()); _session->data().stickers().setLastRecentUpdate(crl::now());
_recentStickersUpdateRequest = 0; _recentStickersUpdateRequest = 0;
@ -3050,7 +3050,7 @@ void ApiWrap::requestFavedStickers(TimeId now) {
} return; } return;
default: Unexpected("Type in ApiWrap::favedStickersDone()"); default: Unexpected("Type in ApiWrap::favedStickersDone()");
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_session->data().stickers().setLastFavedUpdate(crl::now()); _session->data().stickers().setLastFavedUpdate(crl::now());
_favedStickersUpdateRequest = 0; _favedStickersUpdateRequest = 0;
@ -3080,7 +3080,7 @@ void ApiWrap::requestFeaturedStickers(TimeId now) {
} return; } return;
default: Unexpected("Type in ApiWrap::featuredStickersDone()"); default: Unexpected("Type in ApiWrap::featuredStickersDone()");
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_session->data().stickers().setLastFeaturedUpdate(crl::now()); _session->data().stickers().setLastFeaturedUpdate(crl::now());
_featuredStickersUpdateRequest = 0; _featuredStickersUpdateRequest = 0;
@ -3109,7 +3109,7 @@ void ApiWrap::requestSavedGifs(TimeId now) {
} return; } return;
default: Unexpected("Type in ApiWrap::savedGifsDone()"); default: Unexpected("Type in ApiWrap::savedGifsDone()");
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_session->data().stickers().setLastSavedGifsUpdate(crl::now()); _session->data().stickers().setLastSavedGifsUpdate(crl::now());
_savedGifsUpdateRequest = 0; _savedGifsUpdateRequest = 0;
@ -3340,7 +3340,7 @@ void ApiWrap::preloadEnoughUnreadMentions(not_null<History*> history) {
auto requestId = request(MTPmessages_GetUnreadMentions(history->peer->input, MTP_int(offsetId), MTP_int(addOffset), MTP_int(limit), MTP_int(maxId), MTP_int(minId))).done([this, history](const MTPmessages_Messages &result) { auto requestId = request(MTPmessages_GetUnreadMentions(history->peer->input, MTP_int(offsetId), MTP_int(addOffset), MTP_int(limit), MTP_int(maxId), MTP_int(minId))).done([this, history](const MTPmessages_Messages &result) {
_unreadMentionsRequests.remove(history); _unreadMentionsRequests.remove(history);
history->addUnreadMentionsSlice(result); history->addUnreadMentionsSlice(result);
}).fail([this, history](const RPCError &error) { }).fail([this, history](const MTP::Error &error) {
_unreadMentionsRequests.remove(history); _unreadMentionsRequests.remove(history);
}).send(); }).send();
_unreadMentionsRequests.emplace(history, requestId); _unreadMentionsRequests.emplace(history, requestId);
@ -3375,7 +3375,7 @@ void ApiWrap::addChatParticipants(
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
applyUpdates(result); applyUpdates(result);
if (done) done(true); if (done) done(true);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), peer, { 1, user }); ShowAddParticipantsError(error.type(), peer, { 1, user });
if (done) done(false); if (done) done(false);
}).afterDelay(crl::time(5)).send(); }).afterDelay(crl::time(5)).send();
@ -3397,7 +3397,7 @@ void ApiWrap::addChatParticipants(
applyUpdates(result); applyUpdates(result);
requestParticipantsCountDelayed(channel); requestParticipantsCountDelayed(channel);
if (callback) callback(true); if (callback) callback(true);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), peer, users); ShowAddParticipantsError(error.type(), peer, users);
if (callback) callback(false); if (callback) callback(false);
}).afterDelay(crl::time(5)).send(); }).afterDelay(crl::time(5)).send();
@ -3454,7 +3454,7 @@ void ApiWrap::requestSharedMedia(
_sharedMediaRequests.remove(key); _sharedMediaRequests.remove(key);
sharedMediaDone(peer, type, messageId, slice, result); sharedMediaDone(peer, type, messageId, slice, result);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_sharedMediaRequests.remove(key); _sharedMediaRequests.remove(key);
finish(); finish();
}).send(); }).send();
@ -3503,7 +3503,7 @@ void ApiWrap::requestUserPhotos(
)).done([this, user, afterId](const MTPphotos_Photos &result) { )).done([this, user, afterId](const MTPphotos_Photos &result) {
_userPhotosRequests.remove(user); _userPhotosRequests.remove(user);
userPhotosDone(user, afterId, result); userPhotosDone(user, afterId, result);
}).fail([this, user](const RPCError &error) { }).fail([this, user](const MTP::Error &error) {
_userPhotosRequests.remove(user); _userPhotosRequests.remove(user);
}).send(); }).send();
_userPhotosRequests.emplace(user, requestId); _userPhotosRequests.emplace(user, requestId);
@ -3644,7 +3644,7 @@ void ApiWrap::forwardMessages(
shared->callback(); shared->callback();
} }
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (idsCopy) { if (idsCopy) {
for (const auto &[randomId, itemId] : *idsCopy) { for (const auto &[randomId, itemId] : *idsCopy) {
sendMessageFail(error, peer, randomId, itemId); sendMessageFail(error, peer, randomId, itemId);
@ -4098,7 +4098,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
} }
finish(); finish();
}).fail([=]( }).fail([=](
const RPCError &error, const MTP::Error &error,
const MTP::Response &response) { const MTP::Response &response) {
if (error.type() == qstr("MESSAGE_EMPTY")) { if (error.type() == qstr("MESSAGE_EMPTY")) {
lastMessage->destroy(); lastMessage->destroy();
@ -4144,7 +4144,7 @@ void ApiWrap::sendBotStart(not_null<UserData*> bot, PeerData *chat) {
MTP_string(base::take(token)) MTP_string(base::take(token))
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
applyUpdates(result); applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (chat) { if (chat) {
ShowAddParticipantsError(error.type(), chat, { 1, bot }); ShowAddParticipantsError(error.type(), chat, { 1, bot });
} }
@ -4227,7 +4227,7 @@ void ApiWrap::sendInlineResult(
UnixtimeFromMsgId(response.outerMsgId)); UnixtimeFromMsgId(response.outerMsgId));
finish(); finish();
}).fail([=]( }).fail([=](
const RPCError &error, const MTP::Error &error,
const MTP::Response &response) { const MTP::Response &response) {
sendMessageFail(error, peer, randomId, newId); sendMessageFail(error, peer, randomId, newId);
history->finishSavingCloudDraft( history->finishSavingCloudDraft(
@ -4311,7 +4311,7 @@ void ApiWrap::uploadAlbumMedia(
sendAlbumWithUploaded(item, groupId, media); sendAlbumWithUploaded(item, groupId, media);
} break; } break;
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
failed(); failed();
}).send(); }).send();
} }
@ -4373,7 +4373,7 @@ void ApiWrap::sendMediaWithRandomId(
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
applyUpdates(result); applyUpdates(result);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
sendMessageFail(error, peer, randomId, itemId); sendMessageFail(error, peer, randomId, itemId);
finish(); finish();
}).afterRequest( }).afterRequest(
@ -4472,7 +4472,7 @@ void ApiWrap::sendAlbumIfReady(not_null<SendingAlbum*> album) {
_sendingAlbums.remove(groupId); _sendingAlbums.remove(groupId);
applyUpdates(result); applyUpdates(result);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (const auto album = _sendingAlbums.take(groupId)) { if (const auto album = _sendingAlbums.take(groupId)) {
for (const auto &item : (*album)->items) { for (const auto &item : (*album)->items) {
sendMessageFail(error, peer, item.randomId, item.msgId); sendMessageFail(error, peer, item.randomId, item.msgId);
@ -4609,7 +4609,7 @@ void ApiWrap::reloadPasswordState() {
} }
_passwordStateChanges.fire_copy(*_passwordState); _passwordStateChanges.fire_copy(*_passwordState);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_passwordRequestId = 0; _passwordRequestId = 0;
}).send(); }).send();
} }
@ -4619,7 +4619,7 @@ void ApiWrap::clearUnconfirmedPassword() {
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
_passwordRequestId = 0; _passwordRequestId = 0;
reloadPasswordState(); reloadPasswordState();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_passwordRequestId = 0; _passwordRequestId = 0;
reloadPasswordState(); reloadPasswordState();
}).send(); }).send();
@ -4648,7 +4648,7 @@ void ApiWrap::reloadContactSignupSilent() {
const auto silent = mtpIsTrue(result); const auto silent = mtpIsTrue(result);
_contactSignupSilent = silent; _contactSignupSilent = silent;
_contactSignupSilentChanges.fire_copy(silent); _contactSignupSilentChanges.fire_copy(silent);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_contactSignupSilentRequestId = 0; _contactSignupSilentRequestId = 0;
}).send(); }).send();
_contactSignupSilentRequestId = requestId; _contactSignupSilentRequestId = requestId;
@ -4674,7 +4674,7 @@ void ApiWrap::saveContactSignupSilent(bool silent) {
_contactSignupSilentRequestId = 0; _contactSignupSilentRequestId = 0;
_contactSignupSilent = silent; _contactSignupSilent = silent;
_contactSignupSilentChanges.fire_copy(silent); _contactSignupSilentChanges.fire_copy(silent);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_contactSignupSilentRequestId = 0; _contactSignupSilentRequestId = 0;
}).send(); }).send();
_contactSignupSilentRequestId = requestId; _contactSignupSilentRequestId = requestId;
@ -4706,7 +4706,7 @@ void ApiWrap::saveSelfBio(const QString &text, FnMut<void()> done) {
if (_saveBioDone) { if (_saveBioDone) {
_saveBioDone(); _saveBioDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_saveBioRequestId = 0; _saveBioRequestId = 0;
}).send(); }).send();
} }
@ -4724,7 +4724,7 @@ void ApiWrap::reloadPrivacy(Privacy::Key key) {
_session->data().processChats(data.vchats()); _session->data().processChats(data.vchats());
pushPrivacy(key, data.vrules().v); pushPrivacy(key, data.vrules().v);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_privacyRequestIds.erase(key); _privacyRequestIds.erase(key);
}).send(); }).send();
_privacyRequestIds.emplace(key, requestId); _privacyRequestIds.emplace(key, requestId);
@ -4867,7 +4867,7 @@ void ApiWrap::reloadBlockedPeers() {
_session->data().processUsers(data.vusers()); _session->data().processUsers(data.vusers());
push(0, data.vblocked().v); push(0, data.vblocked().v);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_blockedPeersRequestId = 0; _blockedPeersRequestId = 0;
}).send(); }).send();
} }
@ -4909,7 +4909,7 @@ void ApiWrap::createPoll(
const PollData &data, const PollData &data,
const SendAction &action, const SendAction &action,
Fn<void()> done, Fn<void()> done,
Fn<void(const RPCError &error)> fail) { Fn<void(const MTP::Error &error)> fail) {
sendAction(action); sendAction(action);
const auto history = action.history; const auto history = action.history;
@ -4962,7 +4962,7 @@ void ApiWrap::createPoll(
done(); done();
finish(); finish();
}).fail([=]( }).fail([=](
const RPCError &error, const MTP::Error &error,
const MTP::Response &response) mutable { const MTP::Response &response) mutable {
if (clearCloudDraft) { if (clearCloudDraft) {
history->finishSavingCloudDraft( history->finishSavingCloudDraft(
@ -5017,7 +5017,7 @@ void ApiWrap::sendPollVotes(
_pollVotesRequestIds.erase(itemId); _pollVotesRequestIds.erase(itemId);
hideSending(); hideSending();
applyUpdates(result); applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_pollVotesRequestIds.erase(itemId); _pollVotesRequestIds.erase(itemId);
hideSending(); hideSending();
}).send(); }).send();
@ -5046,7 +5046,7 @@ void ApiWrap::closePoll(not_null<HistoryItem*> item) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_pollCloseRequestIds.erase(itemId); _pollCloseRequestIds.erase(itemId);
applyUpdates(result); applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_pollCloseRequestIds.erase(itemId); _pollCloseRequestIds.erase(itemId);
}).send(); }).send();
_pollCloseRequestIds.emplace(itemId, requestId); _pollCloseRequestIds.emplace(itemId, requestId);
@ -5064,7 +5064,7 @@ void ApiWrap::reloadPollResults(not_null<HistoryItem*> item) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_pollReloadRequestIds.erase(itemId); _pollReloadRequestIds.erase(itemId);
applyUpdates(result); applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_pollReloadRequestIds.erase(itemId); _pollReloadRequestIds.erase(itemId);
}).send(); }).send();
_pollReloadRequestIds.emplace(itemId, requestId); _pollReloadRequestIds.emplace(itemId, requestId);

View file

@ -192,7 +192,7 @@ public:
void requestWallPaper( void requestWallPaper(
const QString &slug, const QString &slug,
Fn<void(const Data::WallPaper &)> done, Fn<void(const Data::WallPaper &)> done,
Fn<void(const RPCError &)> fail); Fn<void(const MTP::Error &)> fail);
void requestFullPeer(not_null<PeerData*> peer); void requestFullPeer(not_null<PeerData*> peer);
void requestPeer(not_null<PeerData*> peer); void requestPeer(not_null<PeerData*> peer);
@ -227,7 +227,7 @@ public:
void checkChatInvite( void checkChatInvite(
const QString &hash, const QString &hash,
FnMut<void(const MTPChatInvite &)> done, FnMut<void(const MTPChatInvite &)> done,
Fn<void(const RPCError &)> fail); Fn<void(const MTP::Error &)> fail);
void importChatInvite(const QString &hash); void importChatInvite(const QString &hash);
void requestChannelMembersForAdd( void requestChannelMembersForAdd(
@ -243,7 +243,7 @@ public:
void migrateChat( void migrateChat(
not_null<ChatData*> chat, not_null<ChatData*> chat,
FnMut<void(not_null<ChannelData*>)> done, FnMut<void(not_null<ChannelData*>)> done,
Fn<void(const RPCError &)> fail = nullptr); Fn<void(const MTP::Error &)> fail = nullptr);
void markMediaRead(const base::flat_set<not_null<HistoryItem*>> &items); void markMediaRead(const base::flat_set<not_null<HistoryItem*>> &items);
void markMediaRead(not_null<HistoryItem*> item); void markMediaRead(not_null<HistoryItem*> item);
@ -416,7 +416,7 @@ public:
not_null<InlineBots::Result*> data, not_null<InlineBots::Result*> data,
const SendAction &action); const SendAction &action);
void sendMessageFail( void sendMessageFail(
const RPCError &error, const MTP::Error &error,
not_null<PeerData*> peer, not_null<PeerData*> peer,
uint64 randomId = 0, uint64 randomId = 0,
FullMsgId itemId = FullMsgId()); FullMsgId itemId = FullMsgId());
@ -453,7 +453,7 @@ public:
const PollData &data, const PollData &data,
const SendAction &action, const SendAction &action,
Fn<void()> done, Fn<void()> done,
Fn<void(const RPCError &error)> fail); Fn<void(const MTP::Error &error)> fail);
void sendPollVotes( void sendPollVotes(
FullMsgId itemId, FullMsgId itemId,
const std::vector<QByteArray> &options); const std::vector<QByteArray> &options);
@ -628,7 +628,7 @@ private:
void migrateDone( void migrateDone(
not_null<PeerData*> peer, not_null<PeerData*> peer,
not_null<ChannelData*> channel); not_null<ChannelData*> channel);
void migrateFail(not_null<PeerData*> peer, const RPCError &error); void migrateFail(not_null<PeerData*> peer, const MTP::Error &error);
not_null<Main::Session*> _session; not_null<Main::Session*> _session;
@ -742,11 +742,11 @@ private:
mtpRequestId _checkInviteRequestId = 0; mtpRequestId _checkInviteRequestId = 0;
FnMut<void(const MTPChatInvite &result)> _checkInviteDone; FnMut<void(const MTPChatInvite &result)> _checkInviteDone;
Fn<void(const RPCError &error)> _checkInviteFail; Fn<void(const MTP::Error &error)> _checkInviteFail;
struct MigrateCallbacks { struct MigrateCallbacks {
FnMut<void(not_null<ChannelData*>)> done; FnMut<void(not_null<ChannelData*>)> done;
Fn<void(const RPCError&)> fail; Fn<void(const MTP::Error&)> fail;
}; };
base::flat_map< base::flat_map<
not_null<PeerData*>, not_null<PeerData*>,
@ -786,7 +786,7 @@ private:
mtpRequestId _wallPaperRequestId = 0; mtpRequestId _wallPaperRequestId = 0;
QString _wallPaperSlug; QString _wallPaperSlug;
Fn<void(const Data::WallPaper &)> _wallPaperDone; Fn<void(const Data::WallPaper &)> _wallPaperDone;
Fn<void(const RPCError &)> _wallPaperFail; Fn<void(const MTP::Error &)> _wallPaperFail;
mtpRequestId _contactSignupSilentRequestId = 0; mtpRequestId _contactSignupSilentRequestId = 0;
std::optional<bool> _contactSignupSilent; std::optional<bool> _contactSignupSilent;

View file

@ -586,7 +586,7 @@ void GroupInfoBox::createGroup(
Ui::hideLayer(); // Destroys 'this'. Ui::hideLayer(); // Destroys 'this'.
ChatCreateDone(navigation, std::move(image), result); ChatCreateDone(navigation, std::move(image), result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_creationRequestId = 0; _creationRequestId = 0;
if (error.type() == qstr("NO_CHAT_TITLE")) { if (error.type() == qstr("NO_CHAT_TITLE")) {
auto weak = Ui::MakeWeak(this); auto weak = Ui::MakeWeak(this);
@ -703,7 +703,7 @@ void GroupInfoBox::createChannel(const QString &title, const QString &descriptio
LOG(("API Error: channel not found in updates (GroupInfoBox::creationDone)")); LOG(("API Error: channel not found in updates (GroupInfoBox::creationDone)"));
closeBox(); closeBox();
} }
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
_creationRequestId = 0; _creationRequestId = 0;
if (error.type() == "NO_CHAT_TITLE") { if (error.type() == "NO_CHAT_TITLE") {
_title->setFocus(); _title->setFocus();
@ -824,7 +824,7 @@ void SetupChannelBox::prepare() {
_checkRequestId = _api.request(MTPchannels_CheckUsername( _checkRequestId = _api.request(MTPchannels_CheckUsername(
_channel->inputChannel, _channel->inputChannel,
MTP_string("preston") MTP_string("preston")
)).fail([=](const RPCError &error) { )).fail([=](const MTP::Error &error) {
firstCheckFail(error); firstCheckFail(error);
}).send(); }).send();
@ -983,7 +983,7 @@ void SetupChannelBox::save() {
MTP_string(_sentUsername) MTP_string(_sentUsername)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
updateDone(result); updateDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
updateFail(error); updateFail(error);
}).send(); }).send();
}; };
@ -1055,7 +1055,7 @@ void SetupChannelBox::check() {
MTP_string(link) MTP_string(link)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
checkDone(result); checkDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
checkFail(error); checkFail(error);
}).send(); }).send();
} }
@ -1095,7 +1095,7 @@ void SetupChannelBox::updateDone(const MTPBool &result) {
closeBox(); closeBox();
} }
void SetupChannelBox::updateFail(const RPCError &error) { void SetupChannelBox::updateFail(const MTP::Error &error) {
_saveRequestId = 0; _saveRequestId = 0;
QString err(error.type()); QString err(error.type());
if (err == "USERNAME_NOT_MODIFIED" if (err == "USERNAME_NOT_MODIFIED"
@ -1130,7 +1130,7 @@ void SetupChannelBox::checkDone(const MTPBool &result) {
} }
} }
void SetupChannelBox::checkFail(const RPCError &error) { void SetupChannelBox::checkFail(const MTP::Error &error) {
_checkRequestId = 0; _checkRequestId = 0;
QString err(error.type()); QString err(error.type());
if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) { if (err == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
@ -1171,7 +1171,7 @@ void SetupChannelBox::showRevokePublicLinkBoxForEdit() {
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
} }
void SetupChannelBox::firstCheckFail(const RPCError &error) { void SetupChannelBox::firstCheckFail(const MTP::Error &error) {
_checkRequestId = 0; _checkRequestId = 0;
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("CHANNEL_PUBLIC_GROUP_NA")) { if (type == qstr("CHANNEL_PUBLIC_GROUP_NA")) {
@ -1281,7 +1281,7 @@ void EditNameBox::save() {
MTPstring() MTPstring()
)).done([=](const MTPUser &result) { )).done([=](const MTPUser &result) {
saveSelfDone(result); saveSelfDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
saveSelfFail(error); saveSelfFail(error);
}).send(); }).send();
} }
@ -1291,7 +1291,7 @@ void EditNameBox::saveSelfDone(const MTPUser &user) {
closeBox(); closeBox();
} }
void EditNameBox::saveSelfFail(const RPCError &error) { void EditNameBox::saveSelfFail(const MTP::Error &error) {
auto err = error.type(); auto err = error.type();
auto first = TextUtilities::SingleLine(_first->getLastText().trimmed()); auto first = TextUtilities::SingleLine(_first->getLastText().trimmed());
auto last = TextUtilities::SingleLine(_last->getLastText().trimmed()); auto last = TextUtilities::SingleLine(_last->getLastText().trimmed());

View file

@ -179,11 +179,11 @@ private:
void save(); void save();
void updateDone(const MTPBool &result); void updateDone(const MTPBool &result);
void updateFail(const RPCError &error); void updateFail(const MTP::Error &error);
void checkDone(const MTPBool &result); void checkDone(const MTPBool &result);
void checkFail(const RPCError &error); void checkFail(const MTP::Error &error);
void firstCheckFail(const RPCError &error); void firstCheckFail(const MTP::Error &error);
void updateMaxHeight(); void updateMaxHeight();
@ -229,7 +229,7 @@ private:
void submit(); void submit();
void save(); void save();
void saveSelfDone(const MTPUser &user); void saveSelfDone(const MTPUser &user);
void saveSelfFail(const RPCError &error); void saveSelfFail(const MTP::Error &error);
const not_null<UserData*> _user; const not_null<UserData*> _user;
MTP::Sender _api; MTP::Sender _api;

View file

@ -785,7 +785,7 @@ bool BackgroundPreviewBox::Start(
Ui::show(Box<BackgroundPreviewBox>( Ui::show(Box<BackgroundPreviewBox>(
controller, controller,
result.withUrlParams(params))); result.withUrlParams(params)));
}), [](const RPCError &error) { }), [](const MTP::Error &error) {
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now))); Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
}); });
return true; return true;

View file

@ -78,7 +78,7 @@ protected:
private: private:
void submit(); void submit();
void sendPhoneDone(const MTPauth_SentCode &result, const QString &phoneNumber); void sendPhoneDone(const MTPauth_SentCode &result, const QString &phoneNumber);
void sendPhoneFail(const RPCError &error, const QString &phoneNumber); void sendPhoneFail(const MTP::Error &error, const QString &phoneNumber);
void showError(const QString &text); void showError(const QString &text);
void hideError() { void hideError() {
showError(QString()); showError(QString());
@ -114,7 +114,7 @@ private:
void submit(); void submit();
void sendCall(); void sendCall();
void updateCall(); void updateCall();
void sendCodeFail(const RPCError &error); void sendCodeFail(const MTP::Error &error);
void showError(const QString &text); void showError(const QString &text);
void hideError() { void hideError() {
showError(QString()); showError(QString());
@ -180,7 +180,7 @@ void ChangePhoneBox::EnterPhone::submit() {
MTP_codeSettings(MTP_flags(0)) MTP_codeSettings(MTP_flags(0))
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
sendPhoneDone(result, phoneNumber); sendPhoneDone(result, phoneNumber);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
sendPhoneFail(error, phoneNumber); sendPhoneFail(error, phoneNumber);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -222,9 +222,9 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone(
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
} }
void ChangePhoneBox::EnterPhone::sendPhoneFail(const RPCError &error, const QString &phoneNumber) { void ChangePhoneBox::EnterPhone::sendPhoneFail(const MTP::Error &error, const QString &phoneNumber) {
_requestId = 0; _requestId = 0;
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
showError(tr::lng_flood_error(tr::now)); showError(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("PHONE_NUMBER_INVALID")) { } else if (error.type() == qstr("PHONE_NUMBER_INVALID")) {
showError(tr::lng_bad_phone(tr::now)); showError(tr::lng_bad_phone(tr::now));
@ -320,7 +320,7 @@ void ChangePhoneBox::EnterCode::submit() {
Ui::hideLayer(); Ui::hideLayer();
} }
Ui::Toast::Show(tr::lng_change_phone_success(tr::now)); Ui::Toast::Show(tr::lng_change_phone_success(tr::now));
}).fail(crl::guard(this, [=](const RPCError &error) { }).fail(crl::guard(this, [=](const MTP::Error &error) {
sendCodeFail(error); sendCodeFail(error);
})).handleFloodErrors().send(); })).handleFloodErrors().send();
} }
@ -354,9 +354,9 @@ void ChangePhoneBox::EnterCode::showError(const QString &text) {
} }
} }
void ChangePhoneBox::EnterCode::sendCodeFail(const RPCError &error) { void ChangePhoneBox::EnterCode::sendCodeFail(const MTP::Error &error) {
_requestId = 0; _requestId = 0;
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
showError(tr::lng_flood_error(tr::now)); showError(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) { } else if (error.type() == qstr("PHONE_CODE_EMPTY") || error.type() == qstr("PHONE_CODE_INVALID")) {
showError(tr::lng_bad_code(tr::now)); showError(tr::lng_bad_code(tr::now));

View file

@ -536,7 +536,7 @@ void PinMessageBox::pinMessage() {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
Ui::hideLayer(); Ui::hideLayer();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
Ui::hideLayer(); Ui::hideLayer();
}).send(); }).send();
} }

View file

@ -249,7 +249,7 @@ void ConfirmPhoneBox::checkPhoneAndHash() {
MTP_codeSettings(MTP_flags(0)) MTP_codeSettings(MTP_flags(0))
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
sendCodeDone(result); sendCodeDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
sendCodeFail(error); sendCodeFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -278,9 +278,9 @@ void ConfirmPhoneBox::sendCodeDone(const MTPauth_SentCode &result) {
}); });
} }
void ConfirmPhoneBox::sendCodeFail(const RPCError &error) { void ConfirmPhoneBox::sendCodeFail(const MTP::Error &error) {
auto errorText = Lang::Hard::ServerError(); auto errorText = Lang::Hard::ServerError();
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
errorText = tr::lng_flood_error(tr::now); errorText = tr::lng_flood_error(tr::now);
} else if (error.code() == 400) { } else if (error.code() == 400) {
errorText = tr::lng_confirm_phone_link_invalid(tr::now); errorText = tr::lng_confirm_phone_link_invalid(tr::now);
@ -348,7 +348,7 @@ void ConfirmPhoneBox::sendCode() {
MTP_string(code) MTP_string(code)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
confirmDone(result); confirmDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
confirmFail(error); confirmFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -358,9 +358,9 @@ void ConfirmPhoneBox::confirmDone(const MTPBool &result) {
Ui::show(Box<InformBox>(tr::lng_confirm_phone_success(tr::now, lt_phone, App::formatPhone(_phone)))); Ui::show(Box<InformBox>(tr::lng_confirm_phone_success(tr::now, lt_phone, App::formatPhone(_phone))));
} }
void ConfirmPhoneBox::confirmFail(const RPCError &error) { void ConfirmPhoneBox::confirmFail(const MTP::Error &error) {
auto errorText = Lang::Hard::ServerError(); auto errorText = Lang::Hard::ServerError();
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
errorText = tr::lng_flood_error(tr::now); errorText = tr::lng_flood_error(tr::now);
} else { } else {
auto &errorType = error.type(); auto &errorType = error.type();

View file

@ -121,12 +121,12 @@ private:
void checkPhoneAndHash(); void checkPhoneAndHash();
void sendCodeDone(const MTPauth_SentCode &result); void sendCodeDone(const MTPauth_SentCode &result);
void sendCodeFail(const RPCError &error); void sendCodeFail(const MTP::Error &error);
void callDone(const MTPauth_SentCode &result); void callDone(const MTPauth_SentCode &result);
void confirmDone(const MTPBool &result); void confirmDone(const MTPBool &result);
void confirmFail(const RPCError &error); void confirmFail(const MTP::Error &error);
QString getPhone() const { QString getPhone() const {
return _phone; return _phone;

View file

@ -1061,7 +1061,7 @@ void EditCaptionBox::save() {
closeBox(); closeBox();
}); });
const auto fail = crl::guard(this, [=](const RPCError &error) { const auto fail = crl::guard(this, [=](const MTP::Error &error) {
_saveRequestId = 0; _saveRequestId = 0;
const auto &type = error.type(); const auto &type = error.type();
if (ranges::contains(Api::kDefaultEditMessagesErrors, type)) { if (ranges::contains(Api::kDefaultEditMessagesErrors, type)) {

View file

@ -360,8 +360,8 @@ void PasscodeBox::closeReplacedBy() {
} }
} }
void PasscodeBox::setPasswordFail(const RPCError &error) { void PasscodeBox::setPasswordFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
closeReplacedBy(); closeReplacedBy();
_setRequest = 0; _setRequest = 0;
@ -402,7 +402,7 @@ void PasscodeBox::setPasswordFail(const RPCError &error) {
void PasscodeBox::setPasswordFail( void PasscodeBox::setPasswordFail(
const QByteArray &newPasswordBytes, const QByteArray &newPasswordBytes,
const QString &email, const QString &email,
const RPCError &error) { const MTP::Error &error) {
const auto prefix = qstr("EMAIL_UNCONFIRMED_"); const auto prefix = qstr("EMAIL_UNCONFIRMED_");
if (error.type().startsWith(prefix)) { if (error.type().startsWith(prefix)) {
const auto codeLength = error.type().mid(prefix.size()).toInt(); const auto codeLength = error.type().mid(prefix.size()).toInt();
@ -432,9 +432,9 @@ void PasscodeBox::validateEmail(
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
*set = true; *set = true;
setPasswordDone(newPasswordBytes); setPasswordDone(newPasswordBytes);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_setRequest = 0; _setRequest = 0;
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
errors->fire(tr::lng_flood_error(tr::now)); errors->fire(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("CODE_INVALID")) { } else if (error.type() == qstr("CODE_INVALID")) {
errors->fire(tr::lng_signin_wrong_code(tr::now)); errors->fire(tr::lng_signin_wrong_code(tr::now));
@ -461,7 +461,7 @@ void PasscodeBox::validateEmail(
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
_setRequest = 0; _setRequest = 0;
resent->fire(tr::lng_cloud_password_resent(tr::now)); resent->fire(tr::lng_cloud_password_resent(tr::now));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_setRequest = 0; _setRequest = 0;
errors->fire(Lang::Hard::ServerError()); errors->fire(Lang::Hard::ServerError());
}).send(); }).send();
@ -681,9 +681,9 @@ void PasscodeBox::serverError() {
closeBox(); closeBox();
} }
bool PasscodeBox::handleCustomCheckError(const RPCError &error) { bool PasscodeBox::handleCustomCheckError(const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (MTP::isFloodError(error) if (MTP::IsFloodError(error)
|| type == qstr("PASSWORD_HASH_INVALID") || type == qstr("PASSWORD_HASH_INVALID")
|| type == qstr("SRP_PASSWORD_CHANGED") || type == qstr("SRP_PASSWORD_CHANGED")
|| type == qstr("SRP_ID_INVALID")) { || type == qstr("SRP_ID_INVALID")) {
@ -714,7 +714,7 @@ void PasscodeBox::sendClearCloudPassword(
MTPSecureSecretSettings()) MTPSecureSecretSettings())
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
setPasswordDone({}); setPasswordDone({});
}).fail([=](const RPCError &error) mutable { }).fail([=](const MTP::Error &error) mutable {
setPasswordFail({}, QString(), error); setPasswordFail({}, QString(), error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -745,7 +745,7 @@ void PasscodeBox::setNewCloudPassword(const QString &newPassword) {
MTPSecureSecretSettings()) MTPSecureSecretSettings())
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
setPasswordDone(newPasswordBytes); setPasswordDone(newPasswordBytes);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
setPasswordFail(newPasswordBytes, email, error); setPasswordFail(newPasswordBytes, email, error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -800,7 +800,7 @@ void PasscodeBox::changeCloudPassword(
sendChangeCloudPassword(check, newPassword, secureSecret); sendChangeCloudPassword(check, newPassword, secureSecret);
}); });
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
setPasswordFail(error); setPasswordFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -842,7 +842,7 @@ void PasscodeBox::resetSecret(
const auto empty = QByteArray(); const auto empty = QByteArray();
sendChangeCloudPassword(check, newPassword, empty); sendChangeCloudPassword(check, newPassword, empty);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_setRequest = 0; _setRequest = 0;
if (error.type() == qstr("SRP_ID_INVALID")) { if (error.type() == qstr("SRP_ID_INVALID")) {
handleSrpIdInvalid(); handleSrpIdInvalid();
@ -891,7 +891,7 @@ void PasscodeBox::sendChangeCloudPassword(
MTP_long(newSecureSecretId))) MTP_long(newSecureSecretId)))
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
setPasswordDone(newPasswordBytes); setPasswordDone(newPasswordBytes);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
setPasswordFail(newPasswordBytes, QString(), error); setPasswordFail(newPasswordBytes, QString(), error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -939,7 +939,7 @@ void PasscodeBox::recoverByEmail() {
_api.request(MTPauth_RequestPasswordRecovery( _api.request(MTPauth_RequestPasswordRecovery(
)).done([=](const MTPauth_PasswordRecovery &result) { )).done([=](const MTPauth_PasswordRecovery &result) {
recoverStarted(result); recoverStarted(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
recoverStartFail(error); recoverStartFail(error);
}).send(); }).send();
} else { } else {
@ -977,7 +977,7 @@ void PasscodeBox::recoverStarted(const MTPauth_PasswordRecovery &result) {
recover(); recover();
} }
void PasscodeBox::recoverStartFail(const RPCError &error) { void PasscodeBox::recoverStartFail(const MTP::Error &error) {
_pattern = QString(); _pattern = QString();
closeBox(); closeBox();
} }
@ -1055,7 +1055,7 @@ void RecoverBox::submit() {
MTP_string(code) MTP_string(code)
)).done([=](const MTPauth_Authorization &result) { )).done([=](const MTPauth_Authorization &result) {
codeSubmitDone(result); codeSubmitDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
codeSubmitFail(error); codeSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
}); });
@ -1087,8 +1087,8 @@ void RecoverBox::codeSubmitDone(const MTPauth_Authorization &result) {
Ui::LayerOption::CloseOther); Ui::LayerOption::CloseOther);
} }
void RecoverBox::codeSubmitFail(const RPCError &error) { void RecoverBox::codeSubmitFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
_submitRequest = 0; _submitRequest = 0;
_error = tr::lng_flood_error(tr::now); _error = tr::lng_flood_error(tr::now);
update(); update();
@ -1149,9 +1149,9 @@ RecoveryEmailValidation ConfirmRecoveryEmail(
Box<InformBox>(tr::lng_cloud_password_was_set(tr::now)), Box<InformBox>(tr::lng_cloud_password_was_set(tr::now)),
Ui::LayerOption::CloseOther); Ui::LayerOption::CloseOther);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
*requestId = 0; *requestId = 0;
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
errors->fire(tr::lng_flood_error(tr::now)); errors->fire(tr::lng_flood_error(tr::now));
} else if (error.type() == qstr("CODE_INVALID")) { } else if (error.type() == qstr("CODE_INVALID")) {
errors->fire(tr::lng_signin_wrong_code(tr::now)); errors->fire(tr::lng_signin_wrong_code(tr::now));
@ -1177,7 +1177,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
*requestId = 0; *requestId = 0;
resent->fire(tr::lng_cloud_password_resent(tr::now)); resent->fire(tr::lng_cloud_password_resent(tr::now));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
*requestId = 0; *requestId = 0;
errors->fire(Lang::Hard::ServerError()); errors->fire(Lang::Hard::ServerError());
}).send(); }).send();
@ -1196,7 +1196,7 @@ RecoveryEmailValidation ConfirmRecoveryEmail(
} }
[[nodiscard]] object_ptr<Ui::GenericBox> PrePasswordErrorBox( [[nodiscard]] object_ptr<Ui::GenericBox> PrePasswordErrorBox(
const RPCError &error, const MTP::Error &error,
not_null<Main::Session*> session, not_null<Main::Session*> session,
TextWithEntities &&about) { TextWithEntities &&about) {
const auto type = [&] { const auto type = [&] {

View file

@ -55,7 +55,7 @@ public:
rpl::producer<> passwordReloadNeeded() const; rpl::producer<> passwordReloadNeeded() const;
rpl::producer<> clearUnconfirmedPassword() const; rpl::producer<> clearUnconfirmedPassword() const;
bool handleCustomCheckError(const RPCError &error); bool handleCustomCheckError(const MTP::Error &error);
protected: protected:
void prepare() override; void prepare() override;
@ -81,18 +81,18 @@ private:
bool onlyCheckCurrent() const; bool onlyCheckCurrent() const;
void setPasswordDone(const QByteArray &newPasswordBytes); void setPasswordDone(const QByteArray &newPasswordBytes);
void setPasswordFail(const RPCError &error); void setPasswordFail(const MTP::Error &error);
void setPasswordFail( void setPasswordFail(
const QByteArray &newPasswordBytes, const QByteArray &newPasswordBytes,
const QString &email, const QString &email,
const RPCError &error); const MTP::Error &error);
void validateEmail( void validateEmail(
const QString &email, const QString &email,
int codeLength, int codeLength,
const QByteArray &newPasswordBytes); const QByteArray &newPasswordBytes);
void recoverStarted(const MTPauth_PasswordRecovery &result); void recoverStarted(const MTPauth_PasswordRecovery &result);
void recoverStartFail(const RPCError &error); void recoverStartFail(const MTP::Error &error);
void recover(); void recover();
void submitOnlyCheckCloudPassword(const QString &oldPassword); void submitOnlyCheckCloudPassword(const QString &oldPassword);
@ -189,7 +189,7 @@ private:
void submit(); void submit();
void codeChanged(); void codeChanged();
void codeSubmitDone(const MTPauth_Authorization &result); void codeSubmitDone(const MTPauth_Authorization &result);
void codeSubmitFail(const RPCError &error); void codeSubmitFail(const MTP::Error &error);
MTP::Sender _api; MTP::Sender _api;
mtpRequestId _submitRequest = 0; mtpRequestId _submitRequest = 0;
@ -216,6 +216,6 @@ struct RecoveryEmailValidation {
const QString &pattern); const QString &pattern);
[[nodiscard]] object_ptr<Ui::GenericBox> PrePasswordErrorBox( [[nodiscard]] object_ptr<Ui::GenericBox> PrePasswordErrorBox(
const RPCError &error, const MTP::Error &error,
not_null<Main::Session*> session, not_null<Main::Session*> session,
TextWithEntities &&about); TextWithEntities &&about);

View file

@ -54,7 +54,7 @@ void ShareBotGame(not_null<UserData*> bot, not_null<PeerData*> chat) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
api->applyUpdates(result, randomId); api->applyUpdates(result, randomId);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
api->sendMessageFail(error, chat); api->sendMessageFail(error, chat);
finish(); finish();
}).afterRequest( }).afterRequest(
@ -195,7 +195,7 @@ void PeerListGlobalSearchController::searchOnServer() {
MTP_int(SearchPeopleLimit) MTP_int(SearchPeopleLimit)
)).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) {
searchDone(result, requestId); searchDone(result, requestId);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
if (_requestId == requestId) { if (_requestId == requestId) {
_requestId = 0; _requestId = 0;
delegate()->peerListSearchRefreshRows(); delegate()->peerListSearchRefreshRows();

View file

@ -485,7 +485,7 @@ void AddSpecialBoxController::loadMoreRows() {
setDescriptionText(tr::lng_blocked_list_not_found(tr::now)); setDescriptionText(tr::lng_blocked_list_not_found(tr::now));
} }
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
_loadRequestId = 0; _loadRequestId = 0;
}).send(); }).send();
} }
@ -520,7 +520,7 @@ bool AddSpecialBoxController::checkInfoLoaded(
channel->owner().processUsers(participant.vusers()); channel->owner().processUsers(participant.vusers());
_additional.applyParticipant(participant.vparticipant()); _additional.applyParticipant(participant.vparticipant());
callback(); callback();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_additional.setExternal(user); _additional.setExternal(user);
callback(); callback();
}).send(); }).send();
@ -976,7 +976,7 @@ void AddSpecialBoxSearchController::requestParticipants() {
const MTPchannels_ChannelParticipants &result, const MTPchannels_ChannelParticipants &result,
mtpRequestId requestId) { mtpRequestId requestId) {
searchParticipantsDone(requestId, result, perPage); searchParticipantsDone(requestId, result, perPage);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
if (_requestId == requestId) { if (_requestId == requestId) {
_requestId = 0; _requestId = 0;
_participantsLoaded = true; _participantsLoaded = true;
@ -1059,7 +1059,7 @@ void AddSpecialBoxSearchController::requestGlobal() {
MTP_int(perPage) MTP_int(perPage)
)).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) {
searchGlobalDone(requestId, result); searchGlobalDone(requestId, result);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
if (_requestId == requestId) { if (_requestId == requestId) {
_requestId = 0; _requestId = 0;
_globalLoaded = true; _globalLoaded = true;

View file

@ -75,7 +75,7 @@ void SendRequest(
lt_user, lt_user,
first)); first));
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
}).send(); }).send();
} }

View file

@ -444,7 +444,7 @@ void EditAdminBox::transferOwnership() {
channel, channel,
MTP_inputUserEmpty(), MTP_inputUserEmpty(),
MTP_inputCheckPasswordEmpty() MTP_inputCheckPasswordEmpty()
)).fail([=](const RPCError &error) { )).fail([=](const MTP::Error &error) {
_checkTransferRequestId = 0; _checkTransferRequestId = 0;
if (!handleTransferPasswordError(error)) { if (!handleTransferPasswordError(error)) {
getDelegate()->show(Box<ConfirmBox>( getDelegate()->show(Box<ConfirmBox>(
@ -461,7 +461,7 @@ void EditAdminBox::transferOwnership() {
}).send(); }).send();
} }
bool EditAdminBox::handleTransferPasswordError(const RPCError &error) { bool EditAdminBox::handleTransferPasswordError(const MTP::Error &error) {
const auto session = &user()->session(); const auto session = &user()->session();
auto about = tr::lng_rights_transfer_check_about( auto about = tr::lng_rights_transfer_check_about(
tr::now, tr::now,
@ -533,7 +533,7 @@ void EditAdminBox::sendTransferRequestFrom(
lt_user, lt_user,
user->shortName())); user->shortName()));
Ui::hideLayer(); Ui::hideLayer();
}).fail(crl::guard(this, [=](const RPCError &error) { }).fail(crl::guard(this, [=](const MTP::Error &error) {
if (weak) { if (weak) {
_transferRequestId = 0; _transferRequestId = 0;
} }

View file

@ -10,7 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "base/unique_qptr.h" #include "base/unique_qptr.h"
class RPCError; namespace MTP {
class Error;
} // namespace MTP
namespace Ui { namespace Ui {
class FlatLabel; class FlatLabel;
@ -94,7 +96,7 @@ private:
not_null<Ui::InputField*> addRankInput(); not_null<Ui::InputField*> addRankInput();
void transferOwnership(); void transferOwnership();
void transferOwnershipChecked(); void transferOwnershipChecked();
bool handleTransferPasswordError(const RPCError &error); bool handleTransferPasswordError(const MTP::Error &error);
void requestTransferPassword(not_null<ChannelData*> channel); void requestTransferPassword(not_null<ChannelData*> channel);
void sendTransferRequestFrom( void sendTransferRequestFrom(
QPointer<PasscodeBox> box, QPointer<PasscodeBox> box,

View file

@ -58,7 +58,7 @@ void RemoveAdmin(
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (onFail) { if (onFail) {
onFail(); onFail();
} }
@ -79,7 +79,7 @@ void AddChatParticipant(
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), chat, { 1, user }); ShowAddParticipantsError(error.type(), chat, { 1, user });
if (onFail) { if (onFail) {
onFail(); onFail();
@ -103,7 +103,7 @@ void SaveChatAdmin(
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (retryOnNotParticipant if (retryOnNotParticipant
&& isAdmin && isAdmin
@ -136,7 +136,7 @@ void SaveChannelAdmin(
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
ShowAddParticipantsError(error.type(), channel, { 1, user }); ShowAddParticipantsError(error.type(), channel, { 1, user });
if (onFail) { if (onFail) {
onFail(); onFail();
@ -161,7 +161,7 @@ void SaveChannelRestriction(
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (onFail) { if (onFail) {
onFail(); onFail();
} }
@ -182,7 +182,7 @@ void SaveChatParticipantKick(
if (onDone) { if (onDone) {
onDone(); onDone();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (onFail) { if (onFail) {
onFail(); onFail();
} }
@ -1336,7 +1336,7 @@ void ParticipantsBoxController::loadMoreRows() {
_onlineSorter->sort(); _onlineSorter->sort();
} }
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
_loadRequestId = 0; _loadRequestId = 0;
}).send(); }).send();
} }
@ -2071,7 +2071,7 @@ bool ParticipantsBoxSearchController::loadMoreRows() {
const MTPchannels_ChannelParticipants &result, const MTPchannels_ChannelParticipants &result,
mtpRequestId requestId) { mtpRequestId requestId) {
searchDone(requestId, result, perPage); searchDone(requestId, result, perPage);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
if (_requestId == requestId) { if (_requestId == requestId) {
_requestId = 0; _requestId = 0;
_allLoaded = true; _allLoaded = true;

View file

@ -153,7 +153,7 @@ void SaveDefaultRestrictions(
api->clearModifyRequest(key); api->clearModifyRequest(key);
api->applyUpdates(result); api->applyUpdates(result);
done(); done();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
api->clearModifyRequest(key); api->clearModifyRequest(key);
if (error.type() != qstr("CHAT_NOT_MODIFIED")) { if (error.type() != qstr("CHAT_NOT_MODIFIED")) {
return; return;
@ -186,7 +186,7 @@ void SaveSlowmodeSeconds(
api->applyUpdates(result); api->applyUpdates(result);
channel->setSlowmodeSeconds(seconds); channel->setSlowmodeSeconds(seconds);
done(); done();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
api->clearModifyRequest(key); api->clearModifyRequest(key);
if (error.type() != qstr("CHAT_NOT_MODIFIED")) { if (error.type() != qstr("CHAT_NOT_MODIFIED")) {
return; return;
@ -235,7 +235,7 @@ void ShowEditPermissions(
const auto api = &peer->session().api(); const auto api = &peer->session().api();
api->migrateChat(chat, [=](not_null<ChannelData*> channel) { api->migrateChat(chat, [=](not_null<ChannelData*> channel) {
save(channel, result); save(channel, result);
}, [=](const RPCError &error) { }, [=](const MTP::Error &error) {
*saving = false; *saving = false;
}); });
}, box->lifetime()); }, box->lifetime());
@ -278,7 +278,7 @@ void ShowEditInviteLinks(
const auto api = &peer->session().api(); const auto api = &peer->session().api();
api->migrateChat(chat, [=](not_null<ChannelData*> channel) { api->migrateChat(chat, [=](not_null<ChannelData*> channel) {
save(channel, result); save(channel, result);
}, [=](const RPCError &error) { }, [=](const MTP::Error &error) {
*saving = false; *saving = false;
}); });
}, box->lifetime()); }, box->lifetime());
@ -716,7 +716,7 @@ void Controller::showEditLinkedChatBox() {
std::move(chats), std::move(chats),
callback), callback),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_linkedChatsRequestId = 0; _linkedChatsRequestId = 0;
}).send(); }).send();
} }
@ -1290,7 +1290,7 @@ void Controller::saveUsername() {
TextUtilities::SingleLine(channel->name), TextUtilities::SingleLine(channel->name),
*_savingData.username); *_savingData.username);
continueSave(); continueSave();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("USERNAME_NOT_MODIFIED")) { if (type == qstr("USERNAME_NOT_MODIFIED")) {
channel->setName( channel->setName(
@ -1343,7 +1343,7 @@ void Controller::saveLinkedChat() {
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
channel->setLinkedChat(*_savingData.linkedChat); channel->setLinkedChat(*_savingData.linkedChat);
continueSave(); continueSave();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
cancelSave(); cancelSave();
}).send(); }).send();
@ -1358,7 +1358,7 @@ void Controller::saveTitle() {
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
continueSave(); continueSave();
}; };
const auto onFail = [=](const RPCError &error) { const auto onFail = [=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("CHAT_NOT_MODIFIED") if (type == qstr("CHAT_NOT_MODIFIED")
|| type == qstr("CHAT_TITLE_NOT_MODIFIED")) { || type == qstr("CHAT_TITLE_NOT_MODIFIED")) {
@ -1411,7 +1411,7 @@ void Controller::saveDescription() {
MTP_string(*_savingData.description) MTP_string(*_savingData.description)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
successCallback(); successCallback();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("CHAT_ABOUT_NOT_MODIFIED")) { if (type == qstr("CHAT_ABOUT_NOT_MODIFIED")) {
successCallback(); successCallback();
@ -1469,7 +1469,7 @@ void Controller::togglePreHistoryHidden(
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result); channel->session().api().applyUpdates(result);
apply(); apply();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.type() == qstr("CHAT_NOT_MODIFIED")) { if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
apply(); apply();
} else { } else {
@ -1491,7 +1491,7 @@ void Controller::saveSignatures() {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result); channel->session().api().applyUpdates(result);
continueSave(); continueSave();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.type() == qstr("CHAT_NOT_MODIFIED")) { if (error.type() == qstr("CHAT_NOT_MODIFIED")) {
continueSave(); continueSave();
} else { } else {
@ -1546,7 +1546,7 @@ void Controller::deleteChannel() {
channel->inputChannel channel->inputChannel
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
session->api().applyUpdates(result); session->api().applyUpdates(result);
//}).fail([=](const RPCError &error) { //}).fail([=](const MTP::Error &error) {
// if (error.type() == qstr("CHANNEL_TOO_LARGE")) { // if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now))); // Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now)));
// } // }

View file

@ -525,7 +525,7 @@ void Controller::loadMoreRows() {
auto slice = Api::ParseJoinedByLinkSlice(_peer, result); auto slice = Api::ParseJoinedByLinkSlice(_peer, result);
_allLoaded = slice.users.empty(); _allLoaded = slice.users.empty();
appendSlice(slice); appendSlice(slice);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
_allLoaded = true; _allLoaded = true;
}).send(); }).send();

View file

@ -327,7 +327,7 @@ Fn<void()> AboutGigagroupCallback(not_null<ChannelData*> channel) {
channel->session().api().applyUpdates(result); channel->session().api().applyUpdates(result);
Ui::hideSettingsAndLayer(); Ui::hideSettingsAndLayer();
Ui::Toast::Show(tr::lng_gigagroup_done(tr::now)); Ui::Toast::Show(tr::lng_gigagroup_done(tr::now));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
*converting = false; *converting = false;
}).send(); }).send();
}; };

View file

@ -452,7 +452,7 @@ void Controller::checkUsernameAvailability() {
} else { } else {
showUsernameGood(); showUsernameGood();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_checkUsernameRequestId = 0; _checkUsernameRequestId = 0;
const auto &type = error.type(); const auto &type = error.type();
_usernameState = UsernameState::Normal; _usernameState = UsernameState::Normal;

View file

@ -131,7 +131,7 @@ void RateCallBox::send() {
)).done([=](const MTPUpdates &updates) { )).done([=](const MTPUpdates &updates) {
_session->api().applyUpdates(updates); _session->api().applyUpdates(updates);
closeBox(); closeBox();
}).fail([=](const RPCError &error) { closeBox(); }).send(); }).fail([=](const MTP::Error &error) { closeBox(); }).send();
} }
void RateCallBox::updateMaxHeight() { void RateCallBox::updateMaxHeight() {

View file

@ -275,7 +275,7 @@ void SessionsContent::terminateOne(uint64 hash) {
removeByHash(_data.list); removeByHash(_data.list);
_inner->showData(_data); _inner->showData(_data);
}); });
auto fail = crl::guard(weak, [=](const RPCError &error) { auto fail = crl::guard(weak, [=](const MTP::Error &error) {
_inner->terminatingOne(hash, false); _inner->terminatingOne(hash, false);
}); });
_authorizations->requestTerminate( _authorizations->requestTerminate(
@ -296,7 +296,7 @@ void SessionsContent::terminateAll() {
}); });
_authorizations->requestTerminate( _authorizations->requestTerminate(
[=](const MTPBool &result) { reset(); }, [=](const MTPBool &result) { reset(); },
[=](const RPCError &result) { reset(); }); [=](const MTP::Error &result) { reset(); });
_loading = true; _loading = true;
}; };
terminate(std::move(callback), tr::lng_settings_reset_sure(tr::now)); terminate(std::move(callback), tr::lng_settings_reset_sure(tr::now));

View file

@ -340,7 +340,7 @@ bool ShareBox::searchByUsername(bool searchCache) {
MTP_int(SearchPeopleLimit) MTP_int(SearchPeopleLimit)
)).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) {
peopleDone(result, requestId); peopleDone(result, requestId);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
peopleFail(error, requestId); peopleFail(error, requestId);
}).send(); }).send();
_peopleQueries.insert(_peopleRequest, _peopleQuery); _peopleQueries.insert(_peopleRequest, _peopleQuery);
@ -386,7 +386,7 @@ void ShareBox::peopleDone(
} }
} }
void ShareBox::peopleFail(const RPCError &error, mtpRequestId requestId) { void ShareBox::peopleFail(const MTP::Error &error, mtpRequestId requestId) {
if (_peopleRequest == requestId) { if (_peopleRequest == requestId) {
_peopleRequest = 0; _peopleRequest = 0;
_peopleFull = true; _peopleFull = true;

View file

@ -116,7 +116,7 @@ private:
void peopleDone( void peopleDone(
const MTPcontacts_Found &result, const MTPcontacts_Found &result,
mtpRequestId requestId); mtpRequestId requestId);
void peopleFail(const RPCError &error, mtpRequestId requestId); void peopleFail(const MTP::Error &error, mtpRequestId requestId);
Descriptor _descriptor; Descriptor _descriptor;
MTP::Sender _api; MTP::Sender _api;

View file

@ -272,7 +272,7 @@ StickerSetBox::Inner::Inner(
_input _input
)).done([=](const MTPmessages_StickerSet &result) { )).done([=](const MTPmessages_StickerSet &result) {
gotSet(result); gotSet(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_loaded = true; _loaded = true;
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now))); Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
}).send(); }).send();
@ -758,7 +758,7 @@ void StickerSetBox::Inner::install() {
MTP_bool(false) MTP_bool(false)
)).done([=](const MTPmessages_StickerSetInstallResult &result) { )).done([=](const MTPmessages_StickerSetInstallResult &result) {
installDone(result); installDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now))); Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
}).send(); }).send();
} }

View file

@ -778,7 +778,7 @@ void StickersBox::installSet(uint64 setId) {
MTP_boolFalse() MTP_boolFalse()
)).done([=](const MTPmessages_StickerSetInstallResult &result) { )).done([=](const MTPmessages_StickerSetInstallResult &result) {
installDone(result); installDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
installFail(error, setId); installFail(error, setId);
}).send(); }).send();
@ -793,7 +793,7 @@ void StickersBox::installDone(const MTPmessages_StickerSetInstallResult &result)
} }
} }
void StickersBox::installFail(const RPCError &error, uint64 setId) { void StickersBox::installFail(const MTP::Error &error, uint64 setId) {
const auto &sets = session().data().stickers().sets(); const auto &sets = session().data().stickers().sets();
const auto it = sets.find(setId); const auto it = sets.find(setId);
if (it == sets.cend()) { if (it == sets.cend()) {
@ -1765,7 +1765,7 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
setMegagroupSelectedSet(MTP_inputStickerSetID( setMegagroupSelectedSet(MTP_inputStickerSetID(
MTP_long(set->id), MTP_long(set->id),
MTP_long(set->access))); MTP_long(set->access)));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_megagroupSetRequestId = 0; _megagroupSetRequestId = 0;
setMegagroupSelectedSet(MTP_inputStickerSetEmpty()); setMegagroupSelectedSet(MTP_inputStickerSetEmpty());
}).send(); }).send();

View file

@ -122,7 +122,7 @@ private:
QPixmap grabContentCache(); QPixmap grabContentCache();
void installDone(const MTPmessages_StickerSetInstallResult &result); void installDone(const MTPmessages_StickerSetInstallResult &result);
void installFail(const RPCError &error, uint64 setId); void installFail(const MTP::Error &error, uint64 setId);
void preloadArchivedSets(); void preloadArchivedSets();
void requestArchivedSets(); void requestArchivedSets();

View file

@ -68,7 +68,7 @@ void UrlAuthBox::Activate(
Request(data, item, row, column); Request(data, item, row, column);
} }
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto button = HistoryMessageMarkupButton::Get( const auto button = HistoryMessageMarkupButton::Get(
&session->data(), &session->data(),
itemId, itemId,
@ -106,7 +106,7 @@ void UrlAuthBox::Activate(
}, [&](const MTPDurlAuthResultRequest &data) { }, [&](const MTPDurlAuthResultRequest &data) {
Request(data, session, url, context); Request(data, session, url, context);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
HiddenUrlClickHandler::Open(url, context); HiddenUrlClickHandler::Open(url, context);
}).send(); }).send();
} }
@ -166,7 +166,7 @@ void UrlAuthBox::Request(
return url; return url;
}); });
finishWithUrl(to); finishWithUrl(to);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finishWithUrl(url); finishWithUrl(url);
}).send(); }).send();
} }
@ -217,7 +217,7 @@ void UrlAuthBox::Request(
return url; return url;
}); });
finishWithUrl(to); finishWithUrl(to);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finishWithUrl(url); finishWithUrl(url);
}).send(); }).send();
} }

View file

@ -120,7 +120,7 @@ void UsernameBox::save() {
MTP_string(_sentUsername) MTP_string(_sentUsername)
)).done([=](const MTPUser &result) { )).done([=](const MTPUser &result) {
updateDone(result); updateDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
updateFail(error); updateFail(error);
}).send(); }).send();
} }
@ -135,7 +135,7 @@ void UsernameBox::check() {
MTP_string(name) MTP_string(name)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
checkDone(result); checkDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
checkFail(error); checkFail(error);
}).send(); }).send();
} }
@ -190,7 +190,7 @@ void UsernameBox::updateDone(const MTPUser &user) {
closeBox(); closeBox();
} }
void UsernameBox::updateFail(const RPCError &error) { void UsernameBox::updateFail(const MTP::Error &error) {
_saveRequestId = 0; _saveRequestId = 0;
const auto self = _session->user(); const auto self = _session->user();
const auto &err = error.type(); const auto &err = error.type();
@ -232,7 +232,7 @@ void UsernameBox::checkDone(const MTPBool &result) {
} }
} }
void UsernameBox::checkFail(const RPCError &error) { void UsernameBox::checkFail(const MTP::Error &error) {
_checkRequestId = 0; _checkRequestId = 0;
QString err(error.type()); QString err(error.type());
if (err == qstr("USERNAME_INVALID")) { if (err == qstr("USERNAME_INVALID")) {

View file

@ -32,10 +32,10 @@ protected:
private: private:
void updateDone(const MTPUser &result); void updateDone(const MTPUser &result);
void updateFail(const RPCError &error); void updateFail(const MTP::Error &error);
void checkDone(const MTPBool &result); void checkDone(const MTPBool &result);
void checkFail(const RPCError &error); void checkFail(const MTP::Error &error);
void save(); void save();

View file

@ -343,7 +343,7 @@ void BoxController::loadMoreRows() {
} break; } break;
default: Unexpected("Type of messages.Messages (Calls::BoxController::preloadRows)"); default: Unexpected("Type of messages.Messages (Calls::BoxController::preloadRows)");
} }
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
_loadRequestId = 0; _loadRequestId = 0;
}).send(); }).send();
} }

View file

@ -266,7 +266,7 @@ void Call::startOutgoing() {
const auto &config = _user->session().serverConfig(); const auto &config = _user->session().serverConfig();
_discardByTimeoutTimer.callOnce(config.callReceiveTimeoutMs); _discardByTimeoutTimer.callOnce(config.callReceiveTimeoutMs);
handleUpdate(phoneCall); handleUpdate(phoneCall);
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
handleRequestError(error); handleRequestError(error);
}).send(); }).send();
} }
@ -281,7 +281,7 @@ void Call::startIncoming() {
if (_state.current() == State::Starting) { if (_state.current() == State::Starting) {
setState(State::WaitingIncoming); setState(State::WaitingIncoming);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
handleRequestError(error); handleRequestError(error);
}).send(); }).send();
} }
@ -340,7 +340,7 @@ void Call::actuallyAnswer() {
} }
handleUpdate(call.vphone_call()); handleUpdate(call.vphone_call());
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
handleRequestError(error); handleRequestError(error);
}).send(); }).send();
} }
@ -456,7 +456,7 @@ void Call::sendSignalingData(const QByteArray &data) {
if (!mtpIsTrue(result)) { if (!mtpIsTrue(result)) {
finish(FinishType::Failed); finish(FinishType::Failed);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
handleRequestError(error); handleRequestError(error);
}).send(); }).send();
} }
@ -686,7 +686,7 @@ void Call::confirmAcceptedCall(const MTPDphoneCallAccepted &call) {
} }
createAndStartController(call.vphone_call().c_phoneCall()); createAndStartController(call.vphone_call().c_phoneCall());
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
handleRequestError(error); handleRequestError(error);
}).send(); }).send();
} }
@ -1052,7 +1052,7 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) {
// updates being handled, but in a guarded way. // updates being handled, but in a guarded way.
crl::on_main(weak, [=] { setState(finalState); }); crl::on_main(weak, [=] { setState(finalState); });
session->api().applyUpdates(result); session->api().applyUpdates(result);
}).fail(crl::guard(weak, [this, finalState](const RPCError &error) { }).fail(crl::guard(weak, [this, finalState](const MTP::Error &error) {
setState(finalState); setState(finalState);
})).send(); })).send();
} }
@ -1069,7 +1069,7 @@ void Call::setFailedQueued(const QString &error) {
}); });
} }
void Call::handleRequestError(const RPCError &error) { void Call::handleRequestError(const MTP::Error &error) {
if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) { if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) {
Ui::show(Box<InformBox>(tr::lng_call_error_not_available(tr::now, lt_user, _user->name))); Ui::show(Box<InformBox>(tr::lng_call_error_not_available(tr::now, lt_user, _user->name)));
} else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) { } else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) {

View file

@ -196,7 +196,7 @@ private:
Failed, Failed,
}; };
void handleRequestError(const RPCError &error); void handleRequestError(const MTP::Error &error);
void handleControllerError(const QString &error); void handleControllerError(const QString &error);
void finish( void finish(
FinishType type, FinishType type,

View file

@ -272,7 +272,7 @@ void ChooseJoinAsProcess::start(
_request->box = box.data(); _request->box = box.data();
_request->showBox(std::move(box)); _request->showBox(std::move(box));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finish({ finish({
.peer = _request->peer, .peer = _request->peer,
.joinAs = _request->peer->session().user(), .joinAs = _request->peer->session().user(),

View file

@ -332,7 +332,7 @@ void GroupCall::start() {
_acceptFields = true; _acceptFields = true;
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
_acceptFields = false; _acceptFields = false;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
LOG(("Call Error: Could not create, error: %1" LOG(("Call Error: Could not create, error: %1"
).arg(error.type())); ).arg(error.type()));
hangup(); hangup();
@ -467,7 +467,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
applyMeInCallLocally(); applyMeInCallLocally();
maybeSendMutedUpdate(wasMuteState); maybeSendMutedUpdate(wasMuteState);
_peer->session().api().applyUpdates(updates); _peer->session().api().applyUpdates(updates);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto type = error.type(); const auto type = error.type();
LOG(("Call Error: Could not join, error: %1").arg(type)); LOG(("Call Error: Could not join, error: %1").arg(type));
@ -603,7 +603,7 @@ void GroupCall::discard() {
// updates being handled, but in a guarded way. // updates being handled, but in a guarded way.
crl::on_main(this, [=] { hangup(); }); crl::on_main(this, [=] { hangup(); });
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
hangup(); hangup();
}).send(); }).send();
} }
@ -657,7 +657,7 @@ void GroupCall::finish(FinishType type) {
// updates being handled, but in a guarded way. // updates being handled, but in a guarded way.
crl::on_main(weak, [=] { setState(finalState); }); crl::on_main(weak, [=] { setState(finalState); });
session->api().applyUpdates(result); session->api().applyUpdates(result);
}).fail(crl::guard(weak, [=](const RPCError &error) { }).fail(crl::guard(weak, [=](const MTP::Error &error) {
setState(finalState); setState(finalState);
})).send(); })).send();
} }
@ -911,7 +911,7 @@ void GroupCall::changeTitle(const QString &title) {
MTP_string(title) MTP_string(title)
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
}).send(); }).send();
} }
@ -938,7 +938,7 @@ void GroupCall::toggleRecording(bool enabled, const QString &title) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
_recordingStoppedByMe = false; _recordingStoppedByMe = false;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_recordingStoppedByMe = false; _recordingStoppedByMe = false;
}).send(); }).send();
} }
@ -1060,7 +1060,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
.status = Status::ResyncNeeded, .status = Status::ResyncNeeded,
}); });
}); });
}).fail([=](const RPCError &error, const MTP::Response &response) { }).fail([=](const MTP::Error &error, const MTP::Response &response) {
if (error.type() == u"GROUPCALL_JOIN_MISSING"_q) { if (error.type() == u"GROUPCALL_JOIN_MISSING"_q) {
for (const auto &[task, part] : _broadcastParts) { for (const auto &[task, part] : _broadcastParts) {
_api.request(part.requestId).cancel(); _api.request(part.requestId).cancel();
@ -1069,7 +1069,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
rejoin(); rejoin();
return; return;
} }
const auto status = MTP::isFloodError(error) const auto status = MTP::IsFloodError(error)
? Status::NotReady ? Status::NotReady
: Status::ResyncNeeded; : Status::ResyncNeeded;
finish({ finish({
@ -1248,7 +1248,7 @@ void GroupCall::checkJoined() {
} else if (state() == State::Connecting) { } else if (state() == State::Connecting) {
_checkJoinedTimer.callOnce(kCheckJoinedTimeout); _checkJoinedTimer.callOnce(kCheckJoinedTimeout);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
LOG(("Call Info: Rejoin after error '%1' in checkGroupCall." LOG(("Call Info: Rejoin after error '%1' in checkGroupCall."
).arg(error.type())); ).arg(error.type()));
rejoin(); rejoin();
@ -1320,7 +1320,7 @@ void GroupCall::sendSelfUpdate(SendUpdateType type) {
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_updateMuteRequestId = 0; _updateMuteRequestId = 0;
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_updateMuteRequestId = 0; _updateMuteRequestId = 0;
if (error.type() == u"GROUPCALL_FORBIDDEN"_q) { if (error.type() == u"GROUPCALL_FORBIDDEN"_q) {
LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember." LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember."
@ -1384,7 +1384,7 @@ void GroupCall::editParticipant(
MTPBool() MTPBool()
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
_peer->session().api().applyUpdates(result); _peer->session().api().applyUpdates(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.type() == u"GROUPCALL_FORBIDDEN"_q) { if (error.type() == u"GROUPCALL_FORBIDDEN"_q) {
LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember." LOG(("Call Info: Rejoin after error '%1' in editGroupCallMember."
).arg(error.type())); ).arg(error.type()));
@ -1529,7 +1529,7 @@ void GroupCall::setAudioDuckingEnabled(bool enabled) {
} }
} }
void GroupCall::handleRequestError(const RPCError &error) { void GroupCall::handleRequestError(const MTP::Error &error) {
//if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) { //if (error.type() == qstr("USER_PRIVACY_RESTRICTED")) {
// Ui::show(Box<InformBox>(tr::lng_call_error_not_available(tr::now, lt_user, _user->name))); // Ui::show(Box<InformBox>(tr::lng_call_error_not_available(tr::now, lt_user, _user->name)));
//} else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) { //} else if (error.type() == qstr("PARTICIPANT_VERSION_OUTDATED")) {

View file

@ -209,7 +209,7 @@ private:
RaiseHand, RaiseHand,
}; };
void handleRequestError(const RPCError &error); void handleRequestError(const MTP::Error &error);
void handleControllerError(const QString &error); void handleControllerError(const QString &error);
void ensureControllerCreated(); void ensureControllerCreated();
void destroyController(); void destroyController();

View file

@ -245,7 +245,7 @@ void Instance::refreshDhConfig() {
} else { } else {
callFailed(call); callFailed(call);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
const auto call = weak.get(); const auto call = weak.get();
if (!call) { if (!call) {
return; return;
@ -304,7 +304,7 @@ void Instance::refreshServerConfig(not_null<Main::Session*> session) {
const auto &json = result.c_dataJSON().vdata().v; const auto &json = result.c_dataJSON().vdata().v;
UpdateConfig(std::string(json.data(), json.size())); UpdateConfig(std::string(json.data(), json.size()));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_serverConfigRequestSession = nullptr; _serverConfigRequestSession = nullptr;
}).send(); }).send();
} }

View file

@ -399,7 +399,7 @@ void EmojiKeywords::LangPack::refresh() {
_requestId = 0; _requestId = 0;
_lastRefreshTime = crl::now(); _lastRefreshTime = crl::now();
applyDifference(result); applyDifference(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
_lastRefreshTime = crl::now(); _lastRefreshTime = crl::now();
}).send(); }).send();
@ -670,7 +670,7 @@ void EmojiKeywords::refreshRemoteList() {
}); });
}) | ranges::to_vector); }) | ranges::to_vector);
_langsRequestId = 0; _langsRequestId = 0;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_langsRequestId = 0; _langsRequestId = 0;
}).send(); }).send();
} }

View file

@ -1001,7 +1001,7 @@ void GifsListWidget::sendInlineRequest() {
MTP_string(nextOffset) MTP_string(nextOffset)
)).done([this](const MTPmessages_BotResults &result) { )).done([this](const MTPmessages_BotResults &result) {
inlineResultsDone(result); inlineResultsDone(result);
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
// show error? // show error?
_footer->setLoading(false); _footer->setLoading(false);
_inlineRequestId = 0; _inlineRequestId = 0;

View file

@ -52,7 +52,7 @@ void DicePack::load() {
result.match([&](const MTPDmessages_stickerSet &data) { result.match([&](const MTPDmessages_stickerSet &data) {
applySet(data); applySet(data);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
}).send(); }).send();
} }

View file

@ -220,7 +220,7 @@ void EmojiPack::refresh() {
result.match([&](const MTPDmessages_stickerSet &data) { result.match([&](const MTPDmessages_stickerSet &data) {
applySet(data); applySet(data);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requestId = 0; _requestId = 0;
refreshDelayed(); refreshDelayed();
}).send(); }).send();

View file

@ -1045,7 +1045,7 @@ void StickersListWidget::preloadMoreOfficial() {
}); });
resizeToWidth(width()); resizeToWidth(width());
update(); update();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
}).send(); }).send();
} }
@ -1215,7 +1215,7 @@ void StickersListWidget::sendSearchRequest() {
MTP_int(hash) MTP_int(hash)
)).done([=](const MTPmessages_FoundStickerSets &result) { )).done([=](const MTPmessages_FoundStickerSets &result) {
searchResultsDone(result); searchResultsDone(result);
}).fail([this](const RPCError &error) { }).fail([this](const MTP::Error &error) {
// show error? // show error?
_footer->setLoading(false); _footer->setLoading(false);
_searchRequestId = 0; _searchRequestId = 0;
@ -3066,7 +3066,7 @@ void StickersListWidget::sendInstallRequest(
session().data().stickers().applyArchivedResult( session().data().stickers().applyArchivedResult(
result.c_messages_stickerSetInstallResultArchive()); result.c_messages_stickerSetInstallResultArchive());
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
notInstalledLocally(setId); notInstalledLocally(setId);
session().data().stickers().undoInstallLocally(setId); session().data().stickers().undoInstallLocally(setId);
}).send(); }).send();

View file

@ -183,7 +183,7 @@ private:
using FileLocation = MTP::DedicatedLoader::Location; using FileLocation = MTP::DedicatedLoader::Location;
using Checker::fail; using Checker::fail;
Fn<void(const RPCError &error)> failHandler(); Fn<void(const MTP::Error &error)> failHandler();
void gotMessage(const MTPmessages_Messages &result); void gotMessage(const MTPmessages_Messages &result);
std::optional<FileLocation> parseMessage( std::optional<FileLocation> parseMessage(
@ -1002,8 +1002,8 @@ auto MtpChecker::validateLatestLocation(
return (availableVersion <= myVersion) ? FileLocation() : location; return (availableVersion <= myVersion) ? FileLocation() : location;
} }
Fn<void(const RPCError &error)> MtpChecker::failHandler() { Fn<void(const MTP::Error &error)> MtpChecker::failHandler() {
return [=](const RPCError &error) { return [=](const MTP::Error &error) {
LOG(("Update Error: MTP check failed with '%1'" LOG(("Update Error: MTP check failed with '%1'"
).arg(QString::number(error.code()) + ':' + error.type())); ).arg(QString::number(error.code()) + ':' + error.type()));
fail(); fail();

View file

@ -256,7 +256,7 @@ void ChatFilters::load(bool force) {
)).done([=](const MTPVector<MTPDialogFilter> &result) { )).done([=](const MTPVector<MTPDialogFilter> &result) {
received(result.v); received(result.v);
_loadRequestId = 0; _loadRequestId = 0;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_loadRequestId = 0; _loadRequestId = 0;
}).send(); }).send();
} }
@ -555,7 +555,7 @@ bool ChatFilters::loadNextExceptions(bool chatsListLoaded) {
_exceptionsLoadRequestId = 0; _exceptionsLoadRequestId = 0;
_owner->session().data().histories().applyPeerDialogs(result); _owner->session().data().histories().applyPeerDialogs(result);
_owner->session().api().requestMoreDialogsIfNeeded(); _owner->session().api().requestMoreDialogsIfNeeded();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_exceptionsLoadRequestId = 0; _exceptionsLoadRequestId = 0;
_owner->session().api().requestMoreDialogsIfNeeded(); _owner->session().api().requestMoreDialogsIfNeeded();
}).send(); }).send();
@ -594,7 +594,7 @@ void ChatFilters::requestSuggested() {
}) | ranges::to_vector; }) | ranges::to_vector;
_suggestedUpdated.fire({}); _suggestedUpdated.fire({});
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_suggestedRequestId = 0; _suggestedRequestId = 0;
_suggestedLastReceived = crl::now() + kRefreshSuggestedTimeout / 2; _suggestedLastReceived = crl::now() + kRefreshSuggestedTimeout / 2;

View file

@ -120,7 +120,7 @@ void CloudThemes::reloadCurrent() {
MTP_long(fields.documentId) MTP_long(fields.documentId)
)).done([=](const MTPTheme &result) { )).done([=](const MTPTheme &result) {
applyUpdate(result); applyUpdate(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_reloadCurrentTimer.callOnce(kReloadTimeout); _reloadCurrentTimer.callOnce(kReloadTimeout);
}).send(); }).send();
} }
@ -149,7 +149,7 @@ void CloudThemes::resolve(
MTP_long(0) MTP_long(0)
)).done([=](const MTPTheme &result) { )).done([=](const MTPTheme &result) {
showPreview(result); showPreview(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.type() == qstr("THEME_FORMAT_INVALID")) { if (error.type() == qstr("THEME_FORMAT_INVALID")) {
Ui::show(Box<InformBox>( Ui::show(Box<InformBox>(
tr::lng_theme_no_desktop(tr::now))); tr::lng_theme_no_desktop(tr::now)));
@ -261,7 +261,7 @@ void CloudThemes::refresh() {
_updates.fire({}); _updates.fire({});
}, [](const MTPDaccount_themesNotModified &) { }, [](const MTPDaccount_themesNotModified &) {
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_refreshRquestId = 0; _refreshRquestId = 0;
}).send(); }).send();
} }

View file

@ -103,7 +103,7 @@ void GroupCall::requestParticipants() {
_participantsSliceAdded.fire({}); _participantsSliceAdded.fire({});
_participantsRequestId = 0; _participantsRequestId = 0;
changePeerEmptyCallFlag(); changePeerEmptyCallFlag();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_fullCount = _participants.size(); _fullCount = _participants.size();
_allReceived = true; _allReceived = true;
_participantsRequestId = 0; _participantsRequestId = 0;
@ -236,7 +236,7 @@ void GroupCall::reload() {
_participantsSliceAdded.fire({}); _participantsSliceAdded.fire({});
}); });
_reloadRequestId = 0; _reloadRequestId = 0;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_reloadRequestId = 0; _reloadRequestId = 0;
}).send(); }).send();
} }
@ -563,7 +563,7 @@ void GroupCall::requestUnknownParticipants() {
_unknownSpokenPeerIds.remove(id); _unknownSpokenPeerIds.remove(id);
} }
requestUnknownParticipants(); requestUnknownParticipants();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_unknownParticipantPeersRequestId = 0; _unknownParticipantPeersRequestId = 0;
for (const auto [ssrc, when] : ssrcs) { for (const auto [ssrc, when] : ssrcs) {
_unknownSpokenSsrcs.remove(ssrc); _unknownSpokenSsrcs.remove(ssrc);

View file

@ -266,7 +266,7 @@ void Histories::requestDialogEntry(not_null<Data::Folder*> folder) {
)).done([=](const MTPmessages_PeerDialogs &result) { )).done([=](const MTPmessages_PeerDialogs &result) {
applyPeerDialogs(result); applyPeerDialogs(result);
_dialogFolderRequests.remove(folder); _dialogFolderRequests.remove(folder);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_dialogFolderRequests.remove(folder); _dialogFolderRequests.remove(folder);
}).send(); }).send();
} }
@ -346,7 +346,7 @@ void Histories::sendDialogRequests() {
)).done([=](const MTPmessages_PeerDialogs &result) { )).done([=](const MTPmessages_PeerDialogs &result) {
applyPeerDialogs(result); applyPeerDialogs(result);
finalize(); finalize();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finalize(); finalize();
}).send(); }).send();
} }
@ -426,7 +426,7 @@ void Histories::requestFakeChatListMessage(
_fakeChatListRequests.erase(history); _fakeChatListRequests.erase(history);
history->setFakeChatListMessageFrom(result); history->setFakeChatListMessageFrom(result);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_fakeChatListRequests.erase(history); _fakeChatListRequests.erase(history);
history->setFakeChatListMessageFrom(MTP_messages_messages( history->setFakeChatListMessageFrom(MTP_messages_messages(
MTP_vector<MTPMessage>(0), MTP_vector<MTPMessage>(0),
@ -510,7 +510,7 @@ void Histories::sendReadRequest(not_null<History*> history, State &state) {
MTP_int(tillId) MTP_int(tillId)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
finished(); finished();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finished(); finished();
}).send(); }).send();
} else { } else {
@ -520,7 +520,7 @@ void Histories::sendReadRequest(not_null<History*> history, State &state) {
)).done([=](const MTPmessages_AffectedMessages &result) { )).done([=](const MTPmessages_AffectedMessages &result) {
session().api().applyAffectedMessages(history->peer, result); session().api().applyAffectedMessages(history->peer, result);
finished(); finished();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finished(); finished();
}).send(); }).send();
} }
@ -565,7 +565,7 @@ void Histories::deleteMessages(
finish(); finish();
history->requestChatListMessage(); history->requestChatListMessage();
}; };
const auto fail = [=](const RPCError &error) { const auto fail = [=](const MTP::Error &error) {
finish(); finish();
}; };
if (const auto channel = history->peer->asChannel()) { if (const auto channel = history->peer->asChannel()) {
@ -590,7 +590,7 @@ void Histories::deleteAllMessages(
bool revoke) { bool revoke) {
sendRequest(history, RequestType::Delete, [=](Fn<void()> finish) { sendRequest(history, RequestType::Delete, [=](Fn<void()> finish) {
const auto peer = history->peer; const auto peer = history->peer;
const auto fail = [=](const RPCError &error) { const auto fail = [=](const MTP::Error &error) {
finish(); finish();
}; };
const auto chat = peer->asChat(); const auto chat = peer->asChat();
@ -600,7 +600,7 @@ void Histories::deleteAllMessages(
channel->inputChannel channel->inputChannel
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
session().api().applyUpdates(result); session().api().applyUpdates(result);
//}).fail([=](const RPCError &error) { //}).fail([=](const MTP::Error &error) {
// if (error.type() == qstr("CHANNEL_TOO_LARGE")) { // if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now))); // Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now)));
// } // }
@ -617,7 +617,7 @@ void Histories::deleteAllMessages(
chat->inputChat chat->inputChat
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
if (error.type() == "PEER_ID_INVALID") { if (error.type() == "PEER_ID_INVALID") {
// Try to join and delete, // Try to join and delete,
// while delete fails for non-joined. // while delete fails for non-joined.

View file

@ -412,7 +412,7 @@ void RepliesList::loadAround(MsgId id) {
_skippedBefore = 0; _skippedBefore = 0;
} }
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_beforeId = 0; _beforeId = 0;
_loadingAround = std::nullopt; _loadingAround = std::nullopt;
finish(); finish();
@ -460,7 +460,7 @@ void RepliesList::loadBefore() {
_fullCount = _list.size(); _fullCount = _list.size();
} }
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_beforeId = 0; _beforeId = 0;
finish(); finish();
}).send(); }).send();
@ -504,7 +504,7 @@ void RepliesList::loadAfter() {
_fullCount = _list.size(); _fullCount = _list.size();
} }
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_afterId = 0; _afterId = 0;
finish(); finish();
}).send(); }).send();

View file

@ -383,7 +383,7 @@ void ScheduledMessages::request(not_null<History*> history) {
MTP_int(hash)) MTP_int(hash))
).done([=](const MTPmessages_Messages &result) { ).done([=](const MTPmessages_Messages &result) {
parse(history, result); parse(history, result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_requests.remove(history); _requests.remove(history);
}).send(); }).send();
} }

View file

@ -391,7 +391,7 @@ void SearchController::requestMore(
parsed.noSkipRange, parsed.noSkipRange,
parsed.fullCount); parsed.fullCount);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finish(); finish();
}).send(); }).send();
}); });

View file

@ -545,7 +545,7 @@ void Stickers::requestSetToPushFaved(not_null<DocumentData*> document) {
} }
} }
addAnyway(std::move(list)); addAnyway(std::move(list));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
// Perhaps this is a deleted sticker pack. Add anyway. // Perhaps this is a deleted sticker pack. Add anyway.
addAnyway({}); addAnyway({});
}).send(); }).send();

View file

@ -14,7 +14,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/flags.h" #include "base/flags.h"
#include "base/object_ptr.h" #include "base/object_ptr.h"
class RPCError; namespace MTP {
class Error;
} // namespace MTP
namespace Main { namespace Main {
class Session; class Session;

View file

@ -853,7 +853,7 @@ bool Widget::onSearchMessages(bool searchCache) {
_searchInHistoryRequest = 0; _searchInHistoryRequest = 0;
searchReceived(type, result, _searchRequest); searchReceived(type, result, _searchRequest);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_searchInHistoryRequest = 0; _searchInHistoryRequest = 0;
searchFailed(type, error, _searchRequest); searchFailed(type, error, _searchRequest);
finish(); finish();
@ -880,7 +880,7 @@ bool Widget::onSearchMessages(bool searchCache) {
MTP_int(SearchPerPage) MTP_int(SearchPerPage)
)).done([=](const MTPmessages_Messages &result) { )).done([=](const MTPmessages_Messages &result) {
searchReceived(type, result, _searchRequest); searchReceived(type, result, _searchRequest);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
searchFailed(type, error, _searchRequest); searchFailed(type, error, _searchRequest);
}).send(); }).send();
_searchQueries.emplace(_searchRequest, _searchQuery); _searchQueries.emplace(_searchRequest, _searchQuery);
@ -904,7 +904,7 @@ bool Widget::onSearchMessages(bool searchCache) {
MTP_int(SearchPeopleLimit) MTP_int(SearchPeopleLimit)
)).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) { )).done([=](const MTPcontacts_Found &result, mtpRequestId requestId) {
peerSearchReceived(result, requestId); peerSearchReceived(result, requestId);
}).fail([=](const RPCError &error, mtpRequestId requestId) { }).fail([=](const MTP::Error &error, mtpRequestId requestId) {
peopleFailed(error, requestId); peopleFailed(error, requestId);
}).send(); }).send();
_peerSearchQueries.emplace(_peerSearchRequest, _peerSearchQuery); _peerSearchQueries.emplace(_peerSearchRequest, _peerSearchQuery);
@ -1011,7 +1011,7 @@ void Widget::onSearchMore() {
searchReceived(type, result, _searchRequest); searchReceived(type, result, _searchRequest);
_searchInHistoryRequest = 0; _searchInHistoryRequest = 0;
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
searchFailed(type, error, _searchRequest); searchFailed(type, error, _searchRequest);
_searchInHistoryRequest = 0; _searchInHistoryRequest = 0;
finish(); finish();
@ -1044,7 +1044,7 @@ void Widget::onSearchMore() {
MTP_int(SearchPerPage) MTP_int(SearchPerPage)
)).done([=](const MTPmessages_Messages &result) { )).done([=](const MTPmessages_Messages &result) {
searchReceived(type, result, _searchRequest); searchReceived(type, result, _searchRequest);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
searchFailed(type, error, _searchRequest); searchFailed(type, error, _searchRequest);
}).send(); }).send();
if (!offsetId) { if (!offsetId) {
@ -1084,7 +1084,7 @@ void Widget::onSearchMore() {
searchReceived(type, result, _searchRequest); searchReceived(type, result, _searchRequest);
_searchInHistoryRequest = 0; _searchInHistoryRequest = 0;
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
searchFailed(type, error, _searchRequest); searchFailed(type, error, _searchRequest);
_searchInHistoryRequest = 0; _searchInHistoryRequest = 0;
finish(); finish();
@ -1233,7 +1233,7 @@ void Widget::peerSearchReceived(
void Widget::searchFailed( void Widget::searchFailed(
SearchRequestType type, SearchRequestType type,
const RPCError &error, const MTP::Error &error,
mtpRequestId requestId) { mtpRequestId requestId) {
if (error.type() == qstr("SEARCH_QUERY_EMPTY")) { if (error.type() == qstr("SEARCH_QUERY_EMPTY")) {
searchReceived( searchReceived(
@ -1253,7 +1253,7 @@ void Widget::searchFailed(
} }
} }
void Widget::peopleFailed(const RPCError &error, mtpRequestId requestId) { void Widget::peopleFailed(const MTP::Error &error, mtpRequestId requestId) {
if (_peerSearchRequest == requestId) { if (_peerSearchRequest == requestId) {
_peerSearchRequest = 0; _peerSearchRequest = 0;
_peerSearchFull = true; _peerSearchFull = true;

View file

@ -15,7 +15,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mtproto/sender.h" #include "mtproto/sender.h"
#include "api/api_single_message_search.h" #include "api/api_single_message_search.h"
class RPCError; namespace MTP {
class Error;
} // namespace MTP
namespace Main { namespace Main {
class Session; class Session;
@ -166,9 +168,9 @@ private:
void searchFailed( void searchFailed(
SearchRequestType type, SearchRequestType type,
const RPCError &error, const MTP::Error &error,
mtpRequestId requestId); mtpRequestId requestId);
void peopleFailed(const RPCError &error, mtpRequestId requestId); void peopleFailed(const MTP::Error &error, mtpRequestId requestId);
void scrollToTop(); void scrollToTop();
void setupScrollUpButton(); void setupScrollUpButton();

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "export/data/export_data_types.h" #include "export/data/export_data_types.h"
#include "export/output/export_output_result.h" #include "export/output/export_output_result.h"
#include "export/output/export_output_file.h" #include "export/output/export_output_file.h"
#include "mtproto/mtproto_rpc_sender.h" #include "mtproto/mtproto_response.h"
#include "base/value_ordering.h" #include "base/value_ordering.h"
#include "base/bytes.h" #include "base/bytes.h"
#include <set> #include <set>
@ -249,26 +249,26 @@ public:
RequestBuilder( RequestBuilder(
Original &&builder, Original &&builder,
Fn<void(const RPCError&)> commonFailHandler); Fn<void(const MTP::Error&)> commonFailHandler);
[[nodiscard]] RequestBuilder &done(FnMut<void()> &&handler); [[nodiscard]] RequestBuilder &done(FnMut<void()> &&handler);
[[nodiscard]] RequestBuilder &done( [[nodiscard]] RequestBuilder &done(
FnMut<void(Response &&)> &&handler); FnMut<void(Response &&)> &&handler);
[[nodiscard]] RequestBuilder &fail( [[nodiscard]] RequestBuilder &fail(
Fn<bool(const RPCError&)> &&handler); Fn<bool(const MTP::Error&)> &&handler);
mtpRequestId send(); mtpRequestId send();
private: private:
Original _builder; Original _builder;
Fn<void(const RPCError&)> _commonFailHandler; Fn<void(const MTP::Error&)> _commonFailHandler;
}; };
template <typename Request> template <typename Request>
ApiWrap::RequestBuilder<Request>::RequestBuilder( ApiWrap::RequestBuilder<Request>::RequestBuilder(
Original &&builder, Original &&builder,
Fn<void(const RPCError&)> commonFailHandler) Fn<void(const MTP::Error&)> commonFailHandler)
: _builder(std::move(builder)) : _builder(std::move(builder))
, _commonFailHandler(std::move(commonFailHandler)) { , _commonFailHandler(std::move(commonFailHandler)) {
} }
@ -295,13 +295,13 @@ auto ApiWrap::RequestBuilder<Request>::done(
template <typename Request> template <typename Request>
auto ApiWrap::RequestBuilder<Request>::fail( auto ApiWrap::RequestBuilder<Request>::fail(
Fn<bool(const RPCError &)> &&handler Fn<bool(const MTP::Error &)> &&handler
) -> RequestBuilder& { ) -> RequestBuilder& {
if (handler) { if (handler) {
auto &silence_warning = _builder.fail([ auto &silence_warning = _builder.fail([
common = base::take(_commonFailHandler), common = base::take(_commonFailHandler),
specific = std::move(handler) specific = std::move(handler)
](const RPCError &error) mutable { ](const MTP::Error &error) mutable {
if (!specific(error)) { if (!specific(error)) {
common(error); common(error);
} }
@ -364,7 +364,7 @@ auto ApiWrap::mainRequest(Request &&request) {
return RequestBuilder<MTPInvokeWithTakeout<Request>>( return RequestBuilder<MTPInvokeWithTakeout<Request>>(
std::move(original), std::move(original),
[=](const RPCError &result) { error(result); }); [=](const MTP::Error &result) { error(result); });
} }
template <typename Request> template <typename Request>
@ -391,7 +391,7 @@ auto ApiWrap::fileRequest(const Data::FileLocation &location, int offset) {
location.data, location.data,
MTP_int(offset), MTP_int(offset),
MTP_int(kFileChunkSize)) MTP_int(kFileChunkSize))
)).fail([=](const RPCError &result) { )).fail([=](const MTP::Error &result) {
if (result.type() == qstr("TAKEOUT_FILE_EMPTY") if (result.type() == qstr("TAKEOUT_FILE_EMPTY")
&& _otherDataProcess != nullptr) { && _otherDataProcess != nullptr) {
filePartDone( filePartDone(
@ -418,7 +418,7 @@ ApiWrap::ApiWrap(QPointer<MTP::Instance> weak, Fn<void(FnMut<void()>)> runner)
, _fileCache(std::make_unique<LoadedFileCache>(kLocationCacheSize)) { , _fileCache(std::make_unique<LoadedFileCache>(kLocationCacheSize)) {
} }
rpl::producer<RPCError> ApiWrap::errors() const { rpl::producer<MTP::Error> ApiWrap::errors() const {
return _errors.events(); return _errors.events();
} }
@ -688,10 +688,10 @@ void ApiWrap::startMainSession(FnMut<void()> done) {
return data.vid().v; return data.vid().v;
}); });
done(); done();
}).fail([=](const RPCError &result) { }).fail([=](const MTP::Error &result) {
error(result); error(result);
}).toDC(MTP::ShiftDcId(0, MTP::kExportDcShift)).send(); }).toDC(MTP::ShiftDcId(0, MTP::kExportDcShift)).send();
}).fail([=](const RPCError &result) { }).fail([=](const MTP::Error &result) {
error(result); error(result);
}).send(); }).send();
} }
@ -1454,7 +1454,7 @@ void ApiWrap::requestChatMessages(
MTP_int(0), // max_id MTP_int(0), // max_id
MTP_int(0), // min_id MTP_int(0), // min_id
MTP_int(0) // hash MTP_int(0) // hash
)).fail([=](const RPCError &error) { )).fail([=](const MTP::Error &error) {
Expects(_chatProcess != nullptr); Expects(_chatProcess != nullptr);
if (error.type() == qstr("CHANNEL_PRIVATE")) { if (error.type() == qstr("CHANNEL_PRIVATE")) {
@ -1875,7 +1875,7 @@ void ApiWrap::filePartRefreshReference(int offset) {
MTP_vector<MTPInputMessage>( MTP_vector<MTPInputMessage>(
1, 1,
MTP_inputMessageID(MTP_int(origin.messageId))) MTP_inputMessageID(MTP_int(origin.messageId)))
)).fail([=](const RPCError &error) { )).fail([=](const MTP::Error &error) {
filePartUnavailable(); filePartUnavailable();
return true; return true;
}).done([=](const MTPmessages_Messages &result) { }).done([=](const MTPmessages_Messages &result) {
@ -1886,7 +1886,7 @@ void ApiWrap::filePartRefreshReference(int offset) {
MTP_vector<MTPInputMessage>( MTP_vector<MTPInputMessage>(
1, 1,
MTP_inputMessageID(MTP_int(origin.messageId))) MTP_inputMessageID(MTP_int(origin.messageId)))
)).fail([=](const RPCError &error) { )).fail([=](const MTP::Error &error) {
filePartUnavailable(); filePartUnavailable();
return true; return true;
}).done([=](const MTPmessages_Messages &result) { }).done([=](const MTPmessages_Messages &result) {
@ -1945,12 +1945,12 @@ void ApiWrap::filePartUnavailable() {
base::take(_fileProcess)->done(QString()); base::take(_fileProcess)->done(QString());
} }
void ApiWrap::error(const RPCError &error) { void ApiWrap::error(const MTP::Error &error) {
_errors.fire_copy(error); _errors.fire_copy(error);
} }
void ApiWrap::error(const QString &text) { void ApiWrap::error(const QString &text) {
error(RPCError( error(MTP::Error(
MTP_rpc_error(MTP_int(0), MTP_string("API_ERROR: " + text)))); MTP_rpc_error(MTP_int(0), MTP_string("API_ERROR: " + text))));
} }

View file

@ -37,7 +37,7 @@ class ApiWrap {
public: public:
ApiWrap(QPointer<MTP::Instance> weak, Fn<void(FnMut<void()>)> runner); ApiWrap(QPointer<MTP::Instance> weak, Fn<void(FnMut<void()>)> runner);
rpl::producer<RPCError> errors() const; rpl::producer<MTP::Error> errors() const;
rpl::producer<Output::Result> ioErrors() const; rpl::producer<Output::Result> ioErrors() const;
struct StartInfo { struct StartInfo {
@ -203,7 +203,7 @@ private:
const Data::FileLocation &location, const Data::FileLocation &location,
int offset); int offset);
void error(const RPCError &error); void error(const MTP::Error &error);
void error(const QString &text); void error(const QString &text);
void ioError(const Output::Result &result); void ioError(const Output::Result &result);
@ -226,7 +226,7 @@ private:
std::unique_ptr<ChatProcess> _chatProcess; std::unique_ptr<ChatProcess> _chatProcess;
QVector<MTPMessageRange> _splits; QVector<MTPMessageRange> _splits;
rpl::event_stream<RPCError> _errors; rpl::event_stream<MTP::Error> _errors;
rpl::event_stream<Output::Result> _ioErrors; rpl::event_stream<Output::Result> _ioErrors;
}; };

View file

@ -138,7 +138,7 @@ ControllerObject::ControllerObject(
: _api(mtproto, weak.runner()) : _api(mtproto, weak.runner())
, _state(PasswordCheckState{}) { , _state(PasswordCheckState{}) {
_api.errors( _api.errors(
) | rpl::start_with_next([=](const RPCError &error) { ) | rpl::start_with_next([=](const MTP::Error &error) {
setState(ApiErrorState{ error }); setState(ApiErrorState{ error });
}, _lifetime); }, _lifetime);
@ -211,7 +211,7 @@ bool ControllerObject::ioCatchError(Output::Result result) {
// //)).done([=](const MTPaccount_Password &result) { // //)).done([=](const MTPaccount_Password &result) {
// // _passwordRequestId = 0; // // _passwordRequestId = 0;
// // passwordStateDone(result); // // passwordStateDone(result);
// //}).fail([=](const RPCError &error) { // //}).fail([=](const MTP::Error &error) {
// // apiError(error); // // apiError(error);
// //}).send(); // //}).send();
//} //}

View file

@ -8,7 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once #pragma once
#include "base/variant.h" #include "base/variant.h"
#include "mtproto/mtproto_rpc_sender.h" #include "mtproto/mtproto_response.h"
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <crl/crl_object_on_queue.h> #include <crl/crl_object_on_queue.h>
@ -81,7 +81,7 @@ struct ProcessingState {
}; };
struct ApiErrorState { struct ApiErrorState {
RPCError data; MTP::Error data;
}; };
struct OutputErrorState { struct OutputErrorState {

View file

@ -697,7 +697,7 @@ void InnerWidget::preloadMore(Direction direction) {
if (!loadedFlag) { if (!loadedFlag) {
addEvents(direction, results.vevents().v); addEvents(direction, results.vevents().v);
} }
}).fail([this, &requestId, &loadedFlag](const RPCError &error) { }).fail([this, &requestId, &loadedFlag](const MTP::Error &error) {
requestId = 0; requestId = 0;
loadedFlag = true; loadedFlag = true;
update(); update();
@ -1326,7 +1326,7 @@ void InnerWidget::suggestRestrictUser(not_null<UserData*> user) {
MTP_int(0)); MTP_int(0));
editRestrictions(hasAdminRights, bannedRights); editRestrictions(hasAdminRights, bannedRights);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
auto bannedRights = MTP_chatBannedRights( auto bannedRights = MTP_chatBannedRights(
MTP_flags(0), MTP_flags(0),
MTP_int(0)); MTP_int(0));

View file

@ -330,7 +330,7 @@ void FastShareMessage(not_null<HistoryItem*> item) {
Ui::hideLayer(); Ui::hideLayer();
} }
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
finish(); finish();
}).afterRequest(history->sendRequestId).send(); }).afterRequest(history->sendRequestId).send();
return history->sendRequestId; return history->sendRequestId;

View file

@ -1235,7 +1235,7 @@ void HistoryWidget::updateInlineBotQuery() {
MTP_string(username) MTP_string(username)
)).done([=](const MTPcontacts_ResolvedPeer &result) { )).done([=](const MTPcontacts_ResolvedPeer &result) {
inlineBotResolveDone(result); inlineBotResolveDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
inlineBotResolveFail(error, username); inlineBotResolveFail(error, username);
}).send(); }).send();
} else { } else {
@ -2476,7 +2476,7 @@ void HistoryWidget::unreadCountUpdated() {
} }
} }
void HistoryWidget::messagesFailed(const RPCError &error, int requestId) { void HistoryWidget::messagesFailed(const MTP::Error &error, int requestId) {
if (error.type() == qstr("CHANNEL_PRIVATE") if (error.type() == qstr("CHANNEL_PRIVATE")
&& _peer->isChannel() && _peer->isChannel()
&& _peer->asChannel()->invitePeekExpires()) { && _peer->asChannel()->invitePeekExpires()) {
@ -2714,7 +2714,7 @@ void HistoryWidget::firstLoadMessages() {
)).done([=](const MTPmessages_Messages &result) { )).done([=](const MTPmessages_Messages &result) {
messagesReceived(history->peer, result, _firstLoadRequest); messagesReceived(history->peer, result, _firstLoadRequest);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
messagesFailed(error, _firstLoadRequest); messagesFailed(error, _firstLoadRequest);
finish(); finish();
}).send(); }).send();
@ -2765,7 +2765,7 @@ void HistoryWidget::loadMessages() {
)).done([=](const MTPmessages_Messages &result) { )).done([=](const MTPmessages_Messages &result) {
messagesReceived(history->peer, result, _preloadRequest); messagesReceived(history->peer, result, _preloadRequest);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
messagesFailed(error, _preloadRequest); messagesFailed(error, _preloadRequest);
finish(); finish();
}).send(); }).send();
@ -2816,7 +2816,7 @@ void HistoryWidget::loadMessagesDown() {
)).done([=](const MTPmessages_Messages &result) { )).done([=](const MTPmessages_Messages &result) {
messagesReceived(history->peer, result, _preloadDownRequest); messagesReceived(history->peer, result, _preloadDownRequest);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
messagesFailed(error, _preloadDownRequest); messagesFailed(error, _preloadDownRequest);
finish(); finish();
}).send(); }).send();
@ -2880,7 +2880,7 @@ void HistoryWidget::delayedShowAt(MsgId showAtMsgId) {
)).done([=](const MTPmessages_Messages &result) { )).done([=](const MTPmessages_Messages &result) {
messagesReceived(history->peer, result, _delayedShowAtRequest); messagesReceived(history->peer, result, _delayedShowAtRequest);
finish(); finish();
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
messagesFailed(error, _delayedShowAtRequest); messagesFailed(error, _delayedShowAtRequest);
finish(); finish();
}).send(); }).send();
@ -3105,7 +3105,7 @@ void HistoryWidget::saveEditMsg() {
} }
}; };
const auto fail = [=](const RPCError &error, mtpRequestId requestId) { const auto fail = [=](const MTP::Error &error, mtpRequestId requestId) {
if (const auto editDraft = history->localEditDraft()) { if (const auto editDraft = history->localEditDraft()) {
if (editDraft->saveRequestId == requestId) { if (editDraft->saveRequestId == requestId) {
editDraft->saveRequestId = 0; editDraft->saveRequestId = 0;
@ -3785,7 +3785,7 @@ void HistoryWidget::inlineBotResolveDone(
} }
void HistoryWidget::inlineBotResolveFail( void HistoryWidget::inlineBotResolveFail(
const RPCError &error, const MTP::Error &error,
const QString &username) { const QString &username) {
_inlineBotResolveRequestId = 0; _inlineBotResolveRequestId = 0;
if (username == _inlineBotUsername) { if (username == _inlineBotUsername) {

View file

@ -19,12 +19,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/flags.h" #include "base/flags.h"
#include "base/timer.h" #include "base/timer.h"
class RPCError;
struct FileLoadResult; struct FileLoadResult;
struct SendingAlbum; struct SendingAlbum;
enum class SendMediaType; enum class SendMediaType;
class MessageLinksParser; class MessageLinksParser;
namespace MTP {
class Error;
} // namespace MTP
namespace Data { namespace Data {
enum class PreviewState : char; enum class PreviewState : char;
} // namespace Data } // namespace Data
@ -526,7 +529,7 @@ private:
void requestPreview(); void requestPreview();
void gotPreview(QString links, const MTPMessageMedia &media, mtpRequestId req); void gotPreview(QString links, const MTPMessageMedia &media, mtpRequestId req);
void messagesReceived(PeerData *peer, const MTPmessages_Messages &messages, int requestId); void messagesReceived(PeerData *peer, const MTPmessages_Messages &messages, int requestId);
void messagesFailed(const RPCError &error, int requestId); void messagesFailed(const MTP::Error &error, int requestId);
void addMessagesToFront(PeerData *peer, const QVector<MTPMessage> &messages); void addMessagesToFront(PeerData *peer, const QVector<MTPMessage> &messages);
void addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages); void addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages);
@ -577,7 +580,7 @@ private:
void handleSupportSwitch(not_null<History*> updated); void handleSupportSwitch(not_null<History*> updated);
void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result); void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result);
void inlineBotResolveFail(const RPCError &error, const QString &username); void inlineBotResolveFail(const MTP::Error &error, const QString &username);
bool isRecording() const; bool isRecording() const;

View file

@ -1577,7 +1577,7 @@ void ComposeControls::inlineBotResolveDone(
} }
void ComposeControls::inlineBotResolveFail( void ComposeControls::inlineBotResolveFail(
const RPCError &error, const MTP::Error &error,
const QString &username) { const QString &username) {
_inlineBotResolveRequestId = 0; _inlineBotResolveRequestId = 0;
if (username == _inlineBotUsername) { if (username == _inlineBotUsername) {
@ -2360,7 +2360,7 @@ void ComposeControls::updateInlineBotQuery() {
MTPcontacts_ResolveUsername(MTP_string(username)) MTPcontacts_ResolveUsername(MTP_string(username))
).done([=](const MTPcontacts_ResolvedPeer &result) { ).done([=](const MTPcontacts_ResolvedPeer &result) {
inlineBotResolveDone(result); inlineBotResolveDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
inlineBotResolveFail(error, username); inlineBotResolveFail(error, username);
}).send(); }).send();
} else { } else {

View file

@ -250,7 +250,7 @@ private:
void applyInlineBotQuery(UserData *bot, const QString &query); void applyInlineBotQuery(UserData *bot, const QString &query);
void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result); void inlineBotResolveDone(const MTPcontacts_ResolvedPeer &result);
void inlineBotResolveFail(const RPCError &error, const QString &username); void inlineBotResolveFail(const MTP::Error &error, const QString &username);
[[nodiscard]] Data::DraftKey draftKey( [[nodiscard]] Data::DraftKey draftKey(
DraftType type = DraftType::Normal) const; DraftType type = DraftType::Normal) const;

View file

@ -76,7 +76,7 @@ void AutoDeleteSettingsBox(
if (const auto strong = state->weak.data()) { if (const auto strong = state->weak.data()) {
strong->closeBox(); strong->closeBox();
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
state->savingRequestId = 0; state->savingRequestId = 0;
}).send(); }).send();
}; };

View file

@ -1109,7 +1109,7 @@ void SendReport(
MTP_string(comment) MTP_string(comment)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
Ui::Toast::Show(tr::lng_report_thanks(tr::now)); Ui::Toast::Show(tr::lng_report_thanks(tr::now));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
}).send(); }).send();
} else { } else {
auto apiIds = QVector<MTPint>(); auto apiIds = QVector<MTPint>();
@ -1124,7 +1124,7 @@ void SendReport(
MTP_string(comment) MTP_string(comment)
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
Ui::Toast::Show(tr::lng_report_thanks(tr::now)); Ui::Toast::Show(tr::lng_report_thanks(tr::now));
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
}).send(); }).send();
} }
} }

View file

@ -967,7 +967,7 @@ void RepliesWidget::edit(
} }
}; };
const auto fail = [=](const RPCError &error, mtpRequestId requestId) { const auto fail = [=](const MTP::Error &error, mtpRequestId requestId) {
if (requestId == *saveEditMsgRequestId) { if (requestId == *saveEditMsgRequestId) {
*saveEditMsgRequestId = 0; *saveEditMsgRequestId = 0;
} }

View file

@ -597,7 +597,7 @@ void ScheduledWidget::edit(
} }
}; };
const auto fail = [=](const RPCError &error, mtpRequestId requestId) { const auto fail = [=](const MTP::Error &error, mtpRequestId requestId) {
if (requestId == *saveEditMsgRequestId) { if (requestId == *saveEditMsgRequestId) {
*saveEditMsgRequestId = 0; *saveEditMsgRequestId = 0;
} }

View file

@ -298,7 +298,7 @@ void ListController::loadMoreRows() {
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
} }
_loadRequestId = 0; _loadRequestId = 0;
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_loadRequestId = 0; _loadRequestId = 0;
}).send(); }).send();
} }

View file

@ -448,7 +448,7 @@ void Widget::onInlineRequest() {
MTP_string(nextOffset) MTP_string(nextOffset)
)).done([=](const MTPmessages_BotResults &result) { )).done([=](const MTPmessages_BotResults &result) {
inlineResultsDone(result); inlineResultsDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
// show error? // show error?
_requesting.fire(false); _requesting.fire(false);
_inlineRequestId = 0; _inlineRequestId = 0;

View file

@ -266,8 +266,8 @@ void CodeWidget::codeSubmitDone(const MTPauth_Authorization &result) {
}); });
} }
void CodeWidget::codeSubmitFail(const RPCError &error) { void CodeWidget::codeSubmitFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
showCodeError(tr::lng_flood_error()); showCodeError(tr::lng_flood_error());
@ -288,7 +288,7 @@ void CodeWidget::codeSubmitFail(const RPCError &error) {
_sentRequest = api().request(MTPaccount_GetPassword( _sentRequest = api().request(MTPaccount_GetPassword(
)).done([=](const MTPaccount_Password &result) { )).done([=](const MTPaccount_Password &result) {
gotPassword(result); gotPassword(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
codeSubmitFail(error); codeSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} else if (Logs::DebugEnabled()) { // internal server error } else if (Logs::DebugEnabled()) { // internal server error
@ -391,7 +391,7 @@ void CodeWidget::submit() {
MTP_string(_sentCode) MTP_string(_sentCode)
)).done([=](const MTPauth_Authorization &result) { )).done([=](const MTPauth_Authorization &result) {
codeSubmitDone(result); codeSubmitDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
codeSubmitFail(error); codeSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -405,7 +405,7 @@ void CodeWidget::noTelegramCode() {
MTP_bytes(getData()->phoneHash) MTP_bytes(getData()->phoneHash)
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
noTelegramCodeDone(result); noTelegramCodeDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
noTelegramCodeFail(error); noTelegramCodeFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -433,8 +433,8 @@ void CodeWidget::noTelegramCodeDone(const MTPauth_SentCode &result) {
updateDescText(); updateDescText();
} }
void CodeWidget::noTelegramCodeFail(const RPCError &error) { void CodeWidget::noTelegramCodeFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
_noTelegramCodeRequestId = 0; _noTelegramCodeRequestId = 0;
showCodeError(tr::lng_flood_error()); showCodeError(tr::lng_flood_error());
return; return;

View file

@ -74,14 +74,14 @@ private:
void updateControlsGeometry(); void updateControlsGeometry();
void codeSubmitDone(const MTPauth_Authorization &result); void codeSubmitDone(const MTPauth_Authorization &result);
void codeSubmitFail(const RPCError &error); void codeSubmitFail(const MTP::Error &error);
void showCodeError(rpl::producer<QString> text); void showCodeError(rpl::producer<QString> text);
void callDone(const MTPauth_SentCode &v); void callDone(const MTPauth_SentCode &v);
void gotPassword(const MTPaccount_Password &result); void gotPassword(const MTPaccount_Password &result);
void noTelegramCodeDone(const MTPauth_SentCode &result); void noTelegramCodeDone(const MTPauth_SentCode &result);
void noTelegramCodeFail(const RPCError &result); void noTelegramCodeFail(const MTP::Error &result);
void stopCheck(); void stopCheck();

View file

@ -133,8 +133,8 @@ void PasswordCheckWidget::pwdSubmitDone(bool recover, const MTPauth_Authorizatio
finish(d.vuser()); finish(d.vuser());
} }
void PasswordCheckWidget::pwdSubmitFail(const RPCError &error) { void PasswordCheckWidget::pwdSubmitFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
_sentRequest = 0; _sentRequest = 0;
showError(tr::lng_flood_error()); showError(tr::lng_flood_error());
_pwdField->showError(); _pwdField->showError();
@ -213,7 +213,7 @@ void PasswordCheckWidget::passwordChecked() {
MTPauth_CheckPassword(check.result) MTPauth_CheckPassword(check.result)
).done([=](const MTPauth_Authorization &result) { ).done([=](const MTPauth_Authorization &result) {
pwdSubmitDone(false, result); pwdSubmitDone(false, result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
pwdSubmitFail(error); pwdSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -222,8 +222,8 @@ void PasswordCheckWidget::serverError() {
showError(rpl::single(Lang::Hard::ServerError())); showError(rpl::single(Lang::Hard::ServerError()));
} }
void PasswordCheckWidget::codeSubmitFail(const RPCError &error) { void PasswordCheckWidget::codeSubmitFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
showError(tr::lng_flood_error()); showError(tr::lng_flood_error());
_codeField->showError(); _codeField->showError();
return; return;
@ -258,7 +258,7 @@ void PasswordCheckWidget::recoverStarted(const MTPauth_PasswordRecovery &result)
updateDescriptionText(); updateDescriptionText();
} }
void PasswordCheckWidget::recoverStartFail(const RPCError &error) { void PasswordCheckWidget::recoverStartFail(const MTP::Error &error) {
_pwdField->show(); _pwdField->show();
_pwdHint->show(); _pwdHint->show();
_codeField->hide(); _codeField->hide();
@ -287,7 +287,7 @@ void PasswordCheckWidget::toRecover() {
MTPauth_RequestPasswordRecovery() MTPauth_RequestPasswordRecovery()
).done([=](const MTPauth_PasswordRecovery &result) { ).done([=](const MTPauth_PasswordRecovery &result) {
recoverStarted(result); recoverStarted(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
recoverStartFail(error); recoverStartFail(error);
}).send(); }).send();
} }
@ -343,7 +343,7 @@ void PasswordCheckWidget::submit() {
MTPauth_RecoverPassword(MTP_string(code)) MTPauth_RecoverPassword(MTP_string(code))
).done([=](const MTPauth_Authorization &result) { ).done([=](const MTPauth_Authorization &result) {
pwdSubmitDone(true, result); pwdSubmitDone(true, result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
codeSubmitFail(error); codeSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
}); });

View file

@ -49,9 +49,9 @@ private:
void updateControlsGeometry(); void updateControlsGeometry();
void pwdSubmitDone(bool recover, const MTPauth_Authorization &result); void pwdSubmitDone(bool recover, const MTPauth_Authorization &result);
void pwdSubmitFail(const RPCError &error); void pwdSubmitFail(const MTP::Error &error);
void codeSubmitFail(const RPCError &error); void codeSubmitFail(const MTP::Error &error);
void recoverStartFail(const RPCError &error); void recoverStartFail(const MTP::Error &error);
void recoverStarted(const MTPauth_PasswordRecovery &result); void recoverStarted(const MTPauth_PasswordRecovery &result);

View file

@ -176,7 +176,7 @@ void PhoneWidget::submit() {
MTP_codeSettings(MTP_flags(0)) MTP_codeSettings(MTP_flags(0))
)).done([=](const MTPauth_SentCode &result) { )).done([=](const MTPauth_SentCode &result) {
phoneSubmitDone(result); phoneSubmitDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
phoneSubmitFail(error); phoneSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
} }
@ -222,8 +222,8 @@ void PhoneWidget::phoneSubmitDone(const MTPauth_SentCode &result) {
goNext<CodeWidget>(); goNext<CodeWidget>();
} }
void PhoneWidget::phoneSubmitFail(const RPCError &error) { void PhoneWidget::phoneSubmitFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
stopCheck(); stopCheck();
_sentRequest = 0; _sentRequest = 0;
showPhoneError(tr::lng_flood_error()); showPhoneError(tr::lng_flood_error());

View file

@ -50,7 +50,7 @@ private:
void countryChanged(); void countryChanged();
void phoneSubmitDone(const MTPauth_SentCode &result); void phoneSubmitDone(const MTPauth_SentCode &result);
void phoneSubmitFail(const RPCError &error); void phoneSubmitFail(const MTP::Error &error);
QString fullNumber() const; QString fullNumber() const;
void stopCheck(); void stopCheck();

View file

@ -298,7 +298,7 @@ void QrWidget::refreshCode() {
MTP_vector<MTPint>(0) MTP_vector<MTPint>(0)
)).done([=](const MTPauth_LoginToken &result) { )).done([=](const MTPauth_LoginToken &result) {
handleTokenResult(result); handleTokenResult(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
showTokenError(error); showTokenError(error);
}).send(); }).send();
} }
@ -321,7 +321,7 @@ void QrWidget::handleTokenResult(const MTPauth_LoginToken &result) {
}); });
} }
void QrWidget::showTokenError(const RPCError &error) { void QrWidget::showTokenError(const MTP::Error &error) {
_requestId = 0; _requestId = 0;
if (error.type() == qstr("SESSION_PASSWORD_NEEDED")) { if (error.type() == qstr("SESSION_PASSWORD_NEEDED")) {
sendCheckPasswordRequest(); sendCheckPasswordRequest();
@ -345,7 +345,7 @@ void QrWidget::importTo(MTP::DcId dcId, const QByteArray &token) {
MTP_bytes(token) MTP_bytes(token)
)).done([=](const MTPauth_LoginToken &result) { )).done([=](const MTPauth_LoginToken &result) {
handleTokenResult(result); handleTokenResult(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
showTokenError(error); showTokenError(error);
}).toDC(dcId).send(); }).toDC(dcId).send();
} }
@ -391,7 +391,7 @@ void QrWidget::sendCheckPasswordRequest() {
getData()->pwdNotEmptyPassport = data.is_has_secure_values(); getData()->pwdNotEmptyPassport = data.is_has_secure_values();
goReplace<PasswordCheckWidget>(Animate::Forward); goReplace<PasswordCheckWidget>(Animate::Forward);
}); });
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
showTokenError(error); showTokenError(error);
}).send(); }).send();
} }

View file

@ -47,7 +47,7 @@ private:
void checkForTokenUpdate(const MTPUpdates &updates); void checkForTokenUpdate(const MTPUpdates &updates);
void checkForTokenUpdate(const MTPUpdate &update); void checkForTokenUpdate(const MTPUpdate &update);
void handleTokenResult(const MTPauth_LoginToken &result); void handleTokenResult(const MTPauth_LoginToken &result);
void showTokenError(const RPCError &error); void showTokenError(const MTP::Error &error);
void importTo(MTP::DcId dcId, const QByteArray &token); void importTo(MTP::DcId dcId, const QByteArray &token);
void showToken(const QByteArray &token); void showToken(const QByteArray &token);
void done(const MTPauth_Authorization &authorization); void done(const MTPauth_Authorization &authorization);

View file

@ -117,8 +117,8 @@ void SignupWidget::nameSubmitDone(const MTPauth_Authorization &result) {
finish(d.vuser(), _photo->takeResultImage()); finish(d.vuser(), _photo->takeResultImage());
} }
void SignupWidget::nameSubmitFail(const RPCError &error) { void SignupWidget::nameSubmitFail(const MTP::Error &error) {
if (MTP::isFloodError(error)) { if (MTP::IsFloodError(error)) {
showError(tr::lng_flood_error()); showError(tr::lng_flood_error());
if (_invertOrder) { if (_invertOrder) {
_first->setFocus(); _first->setFocus();
@ -192,7 +192,7 @@ void SignupWidget::submit() {
MTP_string(_lastName) MTP_string(_lastName)
)).done([=](const MTPauth_Authorization &result) { )).done([=](const MTPauth_Authorization &result) {
nameSubmitDone(result); nameSubmitDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
nameSubmitFail(error); nameSubmitFail(error);
}).handleFloodErrors().send(); }).handleFloodErrors().send();
}; };

View file

@ -40,7 +40,7 @@ private:
void updateControlsGeometry(); void updateControlsGeometry();
void nameSubmitDone(const MTPauth_Authorization &result); void nameSubmitDone(const MTPauth_Authorization &result);
void nameSubmitFail(const RPCError &error); void nameSubmitFail(const MTP::Error &error);
object_ptr<Ui::UserpicButton> _photo; object_ptr<Ui::UserpicButton> _photo;
object_ptr<Ui::InputField> _first; object_ptr<Ui::InputField> _first;

View file

@ -166,7 +166,7 @@ void Step::finish(const MTPUser &user, QImage &&photo) {
api().request(MTPmessages_GetDialogFilters( api().request(MTPmessages_GetDialogFilters(
)).done([=](const MTPVector<MTPDialogFilter> &result) { )).done([=](const MTPVector<MTPDialogFilter> &result) {
createSession(user, photo, result.v); createSession(user, photo, result.v);
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
createSession(user, photo, QVector<MTPDialogFilter>()); createSession(user, photo, QVector<MTPDialogFilter>());
}).send(); }).send();
} }

View file

@ -491,7 +491,7 @@ void Widget::resetAccount() {
StackAction::Replace, StackAction::Replace,
Animate::Forward); Animate::Forward);
} }
}).fail([=](const RPCError &error) { }).fail([=](const MTP::Error &error) {
_resetRequest = 0; _resetRequest = 0;
const auto &type = error.type(); const auto &type = error.type();

Some files were not shown because too many files have changed in this diff Show more