Avoid redundant usages of Status::error().
This commit is contained in:
parent
78ba8fa983
commit
5a29dcd337
@ -845,7 +845,7 @@ void AuthManager::on_log_out_result(NetQueryPtr &result) {
|
||||
} else {
|
||||
status = std::move(result->error());
|
||||
}
|
||||
LOG_IF(ERROR, status.is_error() && status.error().code() != 401) << "Receive error for auth.logOut: " << status;
|
||||
LOG_IF(ERROR, status.is_error() && status.code() != 401) << "Receive error for auth.logOut: " << status;
|
||||
// state_ will stay LoggingOut, so no queries will work.
|
||||
destroy_auth_keys();
|
||||
if (query_id_ != 0) {
|
||||
@ -897,7 +897,7 @@ void AuthManager::on_delete_account_result(NetQueryPtr &result) {
|
||||
} else {
|
||||
status = std::move(result->error());
|
||||
}
|
||||
if (status.is_error() && status.error().message() != "USER_DEACTIVATED") {
|
||||
if (status.is_error() && status.message() != "USER_DEACTIVATED") {
|
||||
LOG(WARNING) << "Request account.deleteAccount failed: " << status;
|
||||
// TODO handle some errors
|
||||
if (query_id_ != 0) {
|
||||
|
@ -48,8 +48,7 @@ static std::pair<td_api::object_ptr<td_api::Function>, string> to_request(Slice
|
||||
td_api::object_ptr<td_api::Function> func;
|
||||
auto status = from_json(func, std::move(json_value));
|
||||
if (status.is_error()) {
|
||||
return {get_return_error_function(PSLICE()
|
||||
<< "Failed to parse JSON object as TDLib request: " << status.error().message()),
|
||||
return {get_return_error_function(PSLICE() << "Failed to parse JSON object as TDLib request: " << status.message()),
|
||||
std::move(extra)};
|
||||
}
|
||||
return std::make_pair(std::move(func), std::move(extra));
|
||||
|
@ -9063,9 +9063,9 @@ void MessagesManager::on_upload_media(FileId file_id, tl_object_ptr<telegram_api
|
||||
auto can_send_status = can_send_message(dialog_id);
|
||||
if (!is_edit && can_send_status.is_error()) {
|
||||
// user has left the chat during upload of the file or lost their privileges
|
||||
LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status.error();
|
||||
LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status;
|
||||
|
||||
fail_send_message(full_message_id, can_send_status.move_as_error());
|
||||
fail_send_message(full_message_id, std::move(can_send_status));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -9222,9 +9222,9 @@ void MessagesManager::on_load_secret_thumbnail(FileId thumbnail_file_id, BufferS
|
||||
auto can_send_status = can_send_message(dialog_id);
|
||||
if (can_send_status.is_error()) {
|
||||
// secret chat was closed during load of the file
|
||||
LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status.error();
|
||||
LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status;
|
||||
|
||||
fail_send_message(full_message_id, can_send_status.move_as_error());
|
||||
fail_send_message(full_message_id, std::move(can_send_status));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -9270,9 +9270,9 @@ void MessagesManager::on_upload_thumbnail(FileId thumbnail_file_id,
|
||||
auto can_send_status = can_send_message(dialog_id);
|
||||
if (!is_edit && can_send_status.is_error()) {
|
||||
// user has left the chat during upload of the thumbnail or lost their privileges
|
||||
LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status.error();
|
||||
LOG(INFO) << "Can't send a message to " << dialog_id << ": " << can_send_status;
|
||||
|
||||
fail_send_message(full_message_id, can_send_status.move_as_error());
|
||||
fail_send_message(full_message_id, std::move(can_send_status));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33697,7 +33697,7 @@ void MessagesManager::send_dialog_action(DialogId dialog_id, MessageId top_threa
|
||||
auto can_send_status = can_send_message(dialog_id);
|
||||
if (can_send_status.is_error()) {
|
||||
if (td_->auth_manager_->is_bot()) {
|
||||
return promise.set_error(can_send_status.move_as_error());
|
||||
return promise.set_error(std::move(can_send_status));
|
||||
}
|
||||
return promise.set_value(Unit());
|
||||
}
|
||||
@ -39675,9 +39675,9 @@ MessagesManager::Message *MessagesManager::continue_send_message(DialogId dialog
|
||||
can_send_status = Status::Error(400, "Message is too old to be re-sent automatically");
|
||||
}
|
||||
if (can_send_status.is_error()) {
|
||||
LOG(INFO) << "Can't continue to send a message to " << dialog_id << ": " << can_send_status.error();
|
||||
LOG(INFO) << "Can't continue to send a message to " << dialog_id << ": " << can_send_status;
|
||||
|
||||
fail_send_message({dialog_id, result_message->message_id}, can_send_status.move_as_error());
|
||||
fail_send_message({dialog_id, result_message->message_id}, std::move(can_send_status));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -650,8 +650,8 @@ void SetSecureValue::merge(FileManager *file_manager, FileId file_id, EncryptedS
|
||||
LOG(ERROR) << "Hash mismatch";
|
||||
return;
|
||||
}
|
||||
auto status = file_manager->merge(encrypted_file.file.file_id, file_id);
|
||||
LOG_IF(ERROR, status.is_error()) << status.error();
|
||||
auto r_file_id = file_manager->merge(encrypted_file.file.file_id, file_id);
|
||||
LOG_IF(ERROR, r_file_id.is_error()) << r_file_id.error();
|
||||
}
|
||||
|
||||
class DeleteSecureValue final : public NetQueryCallback {
|
||||
|
@ -8198,7 +8198,7 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseMarkdown &
|
||||
auto entities = r_entities.move_as_ok();
|
||||
auto status = fix_formatted_text(request.text_->text_, entities, true, true, true, true, true);
|
||||
if (status.is_error()) {
|
||||
return make_error(400, status.error().message());
|
||||
return make_error(400, status.message());
|
||||
}
|
||||
|
||||
auto parsed_text = parse_markdown_v3({std::move(request.text_->text_), std::move(entities)});
|
||||
@ -8225,7 +8225,7 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::getMarkdownText
|
||||
auto entities = r_entities.move_as_ok();
|
||||
auto status = fix_formatted_text(request.text_->text_, entities, true, true, true, true, true);
|
||||
if (status.is_error()) {
|
||||
return make_error(400, status.error().message());
|
||||
return make_error(400, status.message());
|
||||
}
|
||||
|
||||
return get_formatted_text_object(get_markdown_v3({std::move(request.text_->text_), std::move(entities)}), false,
|
||||
|
@ -1931,9 +1931,9 @@ class CliClient final : public Actor {
|
||||
HttpReader http_reader;
|
||||
http_reader.init(&reader);
|
||||
HttpQuery query;
|
||||
auto status = http_reader.read_next(&query);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << status.error();
|
||||
auto r_size = http_reader.read_next(&query);
|
||||
if (r_size.is_error()) {
|
||||
LOG(ERROR) << r_size.error();
|
||||
return;
|
||||
}
|
||||
string bot_user_id = query.get_arg("bot_id").str();
|
||||
|
@ -2208,7 +2208,7 @@ void FileManager::download(FileId file_id, std::shared_ptr<DownloadCallback> cal
|
||||
if (node->local_.type() == LocalFileLocation::Type::Full) {
|
||||
auto status = check_local_location(node);
|
||||
if (status.is_error()) {
|
||||
LOG(WARNING) << "Need to redownload file " << file_id << ": " << status.error();
|
||||
LOG(WARNING) << "Need to redownload file " << file_id << ": " << status;
|
||||
} else {
|
||||
LOG(INFO) << "File " << file_id << " is already downloaded";
|
||||
if (callback) {
|
||||
@ -2219,7 +2219,7 @@ void FileManager::download(FileId file_id, std::shared_ptr<DownloadCallback> cal
|
||||
} else if (node->local_.type() == LocalFileLocation::Type::Partial) {
|
||||
auto status = check_local_location(node);
|
||||
if (status.is_error()) {
|
||||
LOG(WARNING) << "Need to download file " << file_id << " from beginning: " << status.error();
|
||||
LOG(WARNING) << "Need to download file " << file_id << " from beginning: " << status;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -426,7 +426,7 @@ void Session::on_bind_result(NetQueryPtr query) {
|
||||
auth_data_.on_bind();
|
||||
last_bind_success_timestamp_ = Time::now();
|
||||
on_tmp_auth_key_updated();
|
||||
} else if (status.error().message() == "DispatchTtlError") {
|
||||
} else if (status.message() == "DispatchTtlError") {
|
||||
LOG(INFO) << "Resend bind auth key " << auth_data_.get_tmp_auth_key().id() << " request after DispatchTtlError";
|
||||
} else {
|
||||
LOG(ERROR) << "BindKey failed: " << status;
|
||||
@ -452,7 +452,7 @@ void Session::on_check_key_result(NetQueryPtr query) {
|
||||
status = r_flag.move_as_error();
|
||||
}
|
||||
}
|
||||
if (status.is_ok() || status.error().code() != -404) {
|
||||
if (status.is_ok() || status.code() != -404) {
|
||||
LOG(INFO) << "Check main key ok";
|
||||
need_check_main_key_ = false;
|
||||
auth_data_.set_use_pfs(true);
|
||||
|
@ -55,7 +55,7 @@ void SqliteKeyValue::set(Slice key, Slice value) {
|
||||
set_stmt_.bind_blob(2, value).ensure();
|
||||
auto status = set_stmt_.step();
|
||||
if (status.is_error()) {
|
||||
LOG(FATAL) << "Failed to set \"" << base64_encode(key) << "\": " << status.error();
|
||||
LOG(FATAL) << "Failed to set \"" << base64_encode(key) << "\": " << status;
|
||||
}
|
||||
set_stmt_.reset();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ Status AsyncFileLog::init(string path, int64 rotate_threshold) {
|
||||
if (size > rotate_threshold) {
|
||||
auto status = rename(path, PSLICE() << path << ".old");
|
||||
if (status.is_error()) {
|
||||
process_fatal_error(PSLICE() << status.error() << " in " << __FILE__ << " at " << __LINE__ << '\n');
|
||||
process_fatal_error(PSLICE() << status << " in " << __FILE__ << " at " << __LINE__ << '\n');
|
||||
}
|
||||
after_rotation();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ void FileLog::do_append(int log_level, CSlice slice) {
|
||||
if (size_ > rotate_threshold_ || want_rotate_.load(std::memory_order_relaxed)) {
|
||||
auto status = rename(path_, PSLICE() << path_ << ".old");
|
||||
if (status.is_error()) {
|
||||
process_fatal_error(PSLICE() << status.error() << " in " << __FILE__ << " at " << __LINE__ << '\n');
|
||||
process_fatal_error(PSLICE() << status << " in " << __FILE__ << " at " << __LINE__ << '\n');
|
||||
}
|
||||
do_after_rotation();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user