From bcc8dbc1581405559c14ba79427f1cd6835fc2d0 Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 31 Mar 2020 00:35:58 +0300 Subject: [PATCH] Use Global::is_expected_error whenever appropriate. GitOrigin-RevId: aba8ee6e3dc1ab6e680a5ae10f6c3d217ab0a8dc --- td/telegram/AnimationsManager.cpp | 4 ++-- td/telegram/BackgroundManager.cpp | 4 ++-- td/telegram/ConfigManager.cpp | 2 +- td/telegram/ContactsManager.cpp | 2 +- td/telegram/DeviceTokenManager.cpp | 2 +- td/telegram/MessagesManager.cpp | 16 ++++++++-------- td/telegram/NotificationManager.cpp | 4 ++-- td/telegram/SecureManager.cpp | 8 ++++---- td/telegram/StickersManager.cpp | 28 ++++++++++++++-------------- td/telegram/Td.cpp | 6 +++--- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/td/telegram/AnimationsManager.cpp b/td/telegram/AnimationsManager.cpp index 467d9de3..aa19b174 100644 --- a/td/telegram/AnimationsManager.cpp +++ b/td/telegram/AnimationsManager.cpp @@ -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); diff --git a/td/telegram/BackgroundManager.cpp b/td/telegram/BackgroundManager.cpp index f3bdcfa2..69300f8e 100644 --- a/td/telegram/BackgroundManager.cpp +++ b/td/telegram/BackgroundManager.cpp @@ -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)); diff --git a/td/telegram/ConfigManager.cpp b/td/telegram/ConfigManager.cpp index b148322b..4f987aab 100644 --- a/td/telegram/ConfigManager.cpp +++ b/td/telegram/ConfigManager.cpp @@ -1093,7 +1093,7 @@ void ConfigManager::on_result(NetQueryPtr res) { auto r_config = fetch_result(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()); } diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index add8446c..5fadd288 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -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; } } diff --git a/td/telegram/DeviceTokenManager.cpp b/td/telegram/DeviceTokenManager.cpp index af05e577..04422328 100644 --- a/td/telegram/DeviceTokenManager.cpp +++ b/td/telegram/DeviceTokenManager.cpp @@ -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()); diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 01199466..ddbf99ab 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -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)); diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index fd439464..56c22ca2 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -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)); diff --git a/td/telegram/SecureManager.cpp b/td/telegram/SecureManager.cpp index 268c11a0..32dfd4d5 100644 --- a/td/telegram/SecureManager.cpp +++ b/td/telegram/SecureManager.cpp @@ -178,7 +178,7 @@ void GetSecureValue::on_error(Status error) { void GetSecureValue::on_secret(Result 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 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 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) { diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 067c30f5..4f188a33 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -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, Resultclose_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> &&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; diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 01b1f1c1..4acd9b97 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -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();