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

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(
Box<StickerSetBox>(strongController, setId),
Ui::LayerOption::KeepOther);
}).fail([=](const RPCError &error) {
}).fail([=](const MTP::Error &error) {
_requestId = 0;
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
}).send();

View File

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

View File

@@ -30,7 +30,7 @@ public:
void cancelCurrentRequest();
void requestTerminate(
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);
[[nodiscard]] crl::time lastReceivedTime();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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