Use Global::is_expected_error whenever appropriate.

GitOrigin-RevId: aba8ee6e3dc1ab6e680a5ae10f6c3d217ab0a8dc
This commit is contained in:
levlam 2020-03-31 00:35:58 +03:00
parent 4cfb7c56d2
commit bcc8dbc158
10 changed files with 38 additions and 38 deletions

View File

@ -59,7 +59,7 @@ class GetSavedGifsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get saved animations: " << status;
}
td->animations_manager_->on_get_saved_animations_failed(is_repair_, std::move(status));
@ -118,7 +118,7 @@ class SaveGifQuery : public Td::ResultHandler {
return;
}
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for save GIF: " << status;
}
td->animations_manager_->reload_saved_animations(true);

View File

@ -197,7 +197,7 @@ class SaveBackgroundQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for save background: " << status;
}
promise_.set_error(std::move(status));
@ -227,7 +227,7 @@ class ResetBackgroundsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for reset backgrounds: " << status;
}
promise_.set_error(std::move(status));

View File

@ -1093,7 +1093,7 @@ void ConfigManager::on_result(NetQueryPtr res) {
auto r_config = fetch_result<telegram_api::help_getConfig>(std::move(res));
if (r_config.is_error()) {
if (!G()->close_flag()) {
LOG(ERROR) << "TODO: getConfig failed: " << r_config.error();
LOG(ERROR) << "getConfig failed: " << r_config.error();
expire_time_ = Timestamp::in(60.0); // try again in a minute
set_timeout_in(expire_time_.in());
}

View File

@ -485,7 +485,7 @@ class GetContactsStatusesQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for getContactsStatuses: " << status;
}
}

View File

@ -418,7 +418,7 @@ void DeviceTokenManager::on_result(NetQueryPtr net_query) {
info.state = TokenInfo::State::Sync;
} else {
if (r_flag.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(r_flag.error())) {
LOG(ERROR) << "Failed to " << info.state << " device: " << r_flag.error();
}
info.promise.set_error(r_flag.move_as_error());

View File

@ -133,7 +133,7 @@ class GetAllDraftsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for GetAllDraftsQuery: " << status;
}
status.ignore();
@ -241,7 +241,7 @@ class GetDialogUnreadMarksQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for GetDialogUnreadMarksQuery: " << status;
}
status.ignore();
@ -550,7 +550,7 @@ class SearchPublicDialogsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for SearchPublicDialogsQuery: " << status;
}
td->messages_manager_->on_failed_public_dialogs_search(query_, std::move(status));
@ -961,7 +961,7 @@ class ClearAllDraftsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ClearAllDraftsQuery: " << status;
}
promise_.set_error(std::move(status));
@ -1049,7 +1049,7 @@ class ReorderPinnedDialogsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReorderPinnedDialogsQuery: " << status;
}
td->messages_manager_->on_update_pinned_dialogs(folder_id_);
@ -1183,7 +1183,7 @@ class ReadMessagesContentsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for read message contents: " << status;
}
promise_.set_error(std::move(status));
@ -2997,7 +2997,7 @@ class DeleteMessagesQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for delete messages: " << status;
}
promise_.set_error(std::move(status));
@ -3363,7 +3363,7 @@ class ResetNotifySettingsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for reset notification settings: " << status;
}
promise_.set_error(std::move(status));

View File

@ -86,7 +86,7 @@ class SetContactSignUpNotificationQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for set contact sign up notification: " << status;
}
promise_.set_error(std::move(status));
@ -115,7 +115,7 @@ class GetContactSignUpNotificationQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag() || 1) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get contact sign up notification: " << status;
}
promise_.set_error(std::move(status));

View File

@ -178,7 +178,7 @@ void GetSecureValue::on_error(Status error) {
void GetSecureValue::on_secret(Result<secure_storage::Secret> r_secret, bool dummy) {
if (r_secret.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(r_secret.error())) {
LOG(ERROR) << "Receive error instead of secret: " << r_secret.error();
}
return on_error(r_secret.move_as_error());
@ -257,7 +257,7 @@ void GetAllSecureValues::on_error(Status error) {
void GetAllSecureValues::on_secret(Result<secure_storage::Secret> r_secret, bool dummy) {
if (r_secret.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(r_secret.error())) {
LOG(ERROR) << "Receive error instead of secret: " << r_secret.error();
}
return on_error(r_secret.move_as_error());
@ -393,7 +393,7 @@ void SetSecureValue::on_error(Status error) {
void SetSecureValue::on_secret(Result<secure_storage::Secret> r_secret, bool x) {
if (r_secret.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(r_secret.error())) {
LOG(ERROR) << "Receive error instead of secret: " << r_secret.error();
}
return on_error(r_secret.move_as_error());
@ -1061,7 +1061,7 @@ void SecureManager::on_get_passport_authorization_form_secret(int32 authorizatio
if (r_secret.is_error()) {
auto error = r_secret.move_as_error();
if (!G()->close_flag()) {
if (!G()->is_expected_error(error)) {
LOG(ERROR) << "Receive error instead of secret: " << error;
}
if (error.code() <= 0) {

View File

@ -82,7 +82,7 @@ class GetAllStickersQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get all stickers: " << status;
}
td->stickers_manager_->on_get_installed_sticker_sets_failed(is_masks_, std::move(status));
@ -110,7 +110,7 @@ class SearchStickersQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for search stickers: " << status;
}
td->stickers_manager_->on_find_stickers_fail(emoji_, std::move(status));
@ -370,7 +370,7 @@ class GetRecentStickersQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get recent " << (is_attached_ ? "attached " : "") << "stickers: " << status;
}
td->stickers_manager_->on_get_recent_stickers_failed(is_repair_, is_attached_, std::move(status));
@ -438,7 +438,7 @@ class SaveRecentStickerQuery : public Td::ResultHandler {
return;
}
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for save recent " << (is_attached_ ? "attached " : "") << "sticker: " << status;
}
td->stickers_manager_->reload_recent_stickers(is_attached_, true);
@ -482,7 +482,7 @@ class ClearRecentStickersQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for clear recent " << (is_attached_ ? "attached " : "") << "stickers: " << status;
}
td->stickers_manager_->reload_recent_stickers(is_attached_, true);
@ -511,7 +511,7 @@ class GetFavedStickersQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for get favorite stickers: " << status;
}
td->stickers_manager_->on_get_favorite_stickers_failed(is_repair_, std::move(status));
@ -571,7 +571,7 @@ class FaveStickerQuery : public Td::ResultHandler {
return;
}
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for fave sticker: " << status;
}
td->stickers_manager_->reload_favorite_stickers(true);
@ -606,10 +606,10 @@ class ReorderStickerSetsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReorderStickerSetsQuery: " << status;
td->stickers_manager_->reload_installed_sticker_sets(is_masks_, true);
}
td->stickers_manager_->reload_installed_sticker_sets(is_masks_, true);
}
};
@ -722,7 +722,7 @@ class SearchStickerSetsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for search sticker sets: " << status;
}
td->stickers_manager_->on_find_sticker_sets_fail(query_, std::move(status));
@ -816,7 +816,7 @@ class ReadFeaturedStickerSetsQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for ReadFeaturedStickerSetsQuery: " << status;
}
td->stickers_manager_->reload_featured_sticker_sets(true);
@ -5194,7 +5194,7 @@ void StickersManager::on_get_language_codes(const string &key, Result<vector<str
load_language_codes_queries_.erase(queries_it);
if (result.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(result.error())) {
LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsLanguageQuery";
}
for (auto &promise : promises) {
@ -5298,7 +5298,7 @@ void StickersManager::on_get_emoji_keywords(
load_emoji_keywords_queries_.erase(it);
if (result.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(result.error())) {
LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsQuery";
}
for (auto &promise : promises) {
@ -5380,7 +5380,7 @@ void StickersManager::on_get_emoji_keywords_difference(
const string &language_code, int32 from_version,
Result<telegram_api::object_ptr<telegram_api::emojiKeywordsDifference>> &&result) {
if (result.is_error()) {
if (!G()->close_flag()) {
if (!G()->is_expected_error(result.error())) {
LOG(ERROR) << "Receive " << result.error() << " from GetEmojiKeywordsDifferenceQuery";
}
emoji_language_code_last_difference_times_[language_code] = Time::now_cached() - EMOJI_KEYWORDS_UPDATE_DELAY - 2;

View File

@ -170,7 +170,7 @@ class GetNearestDcQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag() && status.message() != "BOT_METHOD_INVALID") {
if (!G()->is_expected_error(status) && status.message() != "BOT_METHOD_INVALID") {
LOG(ERROR) << "GetNearestDc returned " << status;
}
promise_.set_error(std::move(status));
@ -347,7 +347,7 @@ class SetBotUpdatesStatusQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (!G()->close_flag()) {
if (!G()->is_expected_error(status)) {
LOG(WARNING) << "Receive error for SetBotUpdatesStatus: " << status;
}
status.ignore();
@ -378,7 +378,7 @@ class UpdateStatusQuery : public Td::ResultHandler {
}
void on_error(uint64 id, Status status) override {
if (status.code() != NetQuery::Cancelled && !G()->close_flag()) {
if (status.code() != NetQuery::Cancelled && !G()->is_expected_error(status)) {
LOG(ERROR) << "Receive error for UpdateStatusQuery: " << status;
}
status.ignore();