From a1e41ac1d43f445931433fe7a140d3a999c6bcab Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 7 Jun 2024 12:26:39 +0300 Subject: [PATCH] Add specific error for failed translation. --- td/telegram/TranslationManager.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/td/telegram/TranslationManager.cpp b/td/telegram/TranslationManager.cpp index 250de4afd..2031b47b4 100644 --- a/td/telegram/TranslationManager.cpp +++ b/td/telegram/TranslationManager.cpp @@ -122,6 +122,9 @@ void TranslationManager::on_get_translated_texts(vector> &&promise) { TRY_STATUS_PROMISE(promise, G()->close_status()); if (texts.size() != 1u) { + if (texts.empty()) { + return promise.set_error(Status::Error(500, "Translation failed")); + } return promise.set_error(Status::Error(500, "Receive invalid number of results")); } auto formatted_text = get_formatted_text(td_->user_manager_.get(), std::move(texts[0]), max_media_timestamp == -1,