Improve error messages.
GitOrigin-RevId: 336ef2751e51381c4dd7905ef5b050b691b91e08
This commit is contained in:
parent
a1e93ebba5
commit
7ec4c26514
@ -43,7 +43,6 @@
|
||||
//}
|
||||
//}
|
||||
|
||||
// TODO: warnings and asserts. There should be no warnings or debug output in production.
|
||||
using qvalue_t = int;
|
||||
|
||||
// Just for testing, not production
|
||||
|
@ -226,7 +226,7 @@ int64 CallbackQueriesManager::send_callback_query(FullMessageId full_message_id,
|
||||
}
|
||||
|
||||
if (payload == nullptr) {
|
||||
promise.set_error(Status::Error(5, "Payload should not be empty"));
|
||||
promise.set_error(Status::Error(5, "Payload must be non-empty"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4633,7 +4633,7 @@ std::pair<vector<UserId>, vector<int32>> ContactsManager::change_imported_contac
|
||||
|
||||
for (auto &contact : contacts) {
|
||||
if (contact == nullptr) {
|
||||
promise.set_error(Status::Error(400, "Contacts should not be empty"));
|
||||
promise.set_error(Status::Error(400, "Contacts must be non-empty"));
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
|
||||
return promise.set_error(Status::Error(400, "Field \"phone_number\" must contain a valid phone number"));
|
||||
}
|
||||
if (first_name.empty()) {
|
||||
return promise.set_error(Status::Error(400, "Field \"first_name\" should be non-empty"));
|
||||
return promise.set_error(Status::Error(400, "Field \"first_name\" must be non-empty"));
|
||||
}
|
||||
title = last_name.empty() ? first_name : first_name + " " + last_name;
|
||||
description = std::move(phone_number);
|
||||
@ -633,7 +633,7 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
|
||||
}
|
||||
auto inline_message = r_inline_message.move_as_ok();
|
||||
if (inline_message->get_id() == telegram_api::inputBotInlineMessageMediaAuto::ID && file_type == FileType::Temp) {
|
||||
return promise.set_error(Status::Error(400, "Sent message content should be explicitly specified"));
|
||||
return promise.set_error(Status::Error(400, "Sent message content must be explicitly specified"));
|
||||
}
|
||||
|
||||
if (duration < 0) {
|
||||
|
@ -59,7 +59,7 @@ Status Logging::set_current_stream(td_api::object_ptr<td_api::LogStream> stream)
|
||||
auto file_stream = td_api::move_object_as<td_api::logStreamFile>(stream);
|
||||
auto max_log_file_size = file_stream->max_file_size_;
|
||||
if (max_log_file_size <= 0) {
|
||||
return Status::Error("Max log file size should be positive");
|
||||
return Status::Error("Max log file size must be positive");
|
||||
}
|
||||
|
||||
TRY_STATUS(file_log.init(file_stream->path_, max_log_file_size));
|
||||
|
@ -697,7 +697,7 @@ Result<Address> address_from_json(Slice json) {
|
||||
|
||||
auto value = r_value.move_as_ok();
|
||||
if (value.type() != JsonValue::Type::Object) {
|
||||
return Status::Error(400, "Address should be an Object");
|
||||
return Status::Error(400, "Address must be an Object");
|
||||
}
|
||||
|
||||
auto &object = value.get_object();
|
||||
|
@ -27,7 +27,7 @@ namespace td {
|
||||
Result<PrivacyManager::UserPrivacySetting> PrivacyManager::UserPrivacySetting::from_td_api(
|
||||
tl_object_ptr<td_api::UserPrivacySetting> key) {
|
||||
if (!key) {
|
||||
return Status::Error(5, "UserPrivacySetting should not be empty");
|
||||
return Status::Error(5, "UserPrivacySetting must be non-empty");
|
||||
}
|
||||
return UserPrivacySetting(*key);
|
||||
}
|
||||
@ -368,12 +368,12 @@ Result<PrivacyManager::UserPrivacySettingRules> PrivacyManager::UserPrivacySetti
|
||||
Result<PrivacyManager::UserPrivacySettingRules> PrivacyManager::UserPrivacySettingRules::from_td_api(
|
||||
tl_object_ptr<td_api::userPrivacySettingRules> rules) {
|
||||
if (!rules) {
|
||||
return Status::Error(5, "UserPrivacySettingRules should not be empty");
|
||||
return Status::Error(5, "UserPrivacySettingRules must be non-empty");
|
||||
}
|
||||
UserPrivacySettingRules result;
|
||||
for (auto &rule : rules->rules_) {
|
||||
if (!rule) {
|
||||
return Status::Error(5, "UserPrivacySettingRule should not be empty");
|
||||
return Status::Error(5, "UserPrivacySettingRule must be non-empty");
|
||||
}
|
||||
result.rules_.emplace_back(*rule);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ Result<BufferSlice> Decryptor::append(BufferSlice data) {
|
||||
return BufferSlice();
|
||||
}
|
||||
if (data.size() % 16 != 0) {
|
||||
return Status::Error("Part size should be divisible by 16");
|
||||
return Status::Error("Part size must be divisible by 16");
|
||||
}
|
||||
aes_cbc_state_.decrypt(data.as_slice(), data.as_slice());
|
||||
sha256_state_.feed(data.as_slice());
|
||||
@ -330,7 +330,7 @@ Result<BufferSlice> Encryptor::pread(int64 offset, int64 size) const {
|
||||
return Status::Error("Arbitrary offset is not supported");
|
||||
}
|
||||
if (size % 16 != 0) {
|
||||
return Status::Error("Part size should be divisible by 16");
|
||||
return Status::Error("Part size must be divisible by 16");
|
||||
}
|
||||
TRY_RESULT(part, data_view_.pread(offset, size));
|
||||
aes_cbc_state_.encrypt(part.as_slice(), part.as_slice());
|
||||
|
@ -796,7 +796,7 @@ static Result<td_api::object_ptr<td_api::personalDetails>> get_personal_details_
|
||||
|
||||
auto value = r_value.move_as_ok();
|
||||
if (value.type() != JsonValue::Type::Object) {
|
||||
return Status::Error(400, "Personal details should be an Object");
|
||||
return Status::Error(400, "Personal details must be an Object");
|
||||
}
|
||||
|
||||
auto &object = value.get_object();
|
||||
@ -888,7 +888,7 @@ static Result<SecureValue> get_identity_document(SecureValueType type, FileManag
|
||||
}
|
||||
} else {
|
||||
if (!need_reverse_side) {
|
||||
return Status::Error(400, "Document shouldn't have a reverse side");
|
||||
return Status::Error(400, "Document can't have a reverse side");
|
||||
}
|
||||
}
|
||||
|
||||
@ -930,7 +930,7 @@ static Result<td_api::object_ptr<td_api::identityDocument>> get_identity_documen
|
||||
|
||||
auto json_value = r_value.move_as_ok();
|
||||
if (json_value.type() != JsonValue::Type::Object) {
|
||||
return Status::Error(400, "Identity document should be an Object");
|
||||
return Status::Error(400, "Identity document must be an Object");
|
||||
}
|
||||
|
||||
auto &object = json_value.get_object();
|
||||
|
@ -4759,7 +4759,7 @@ void Td::on_request(uint64 id, td_api::processPushNotification &request) {
|
||||
void Td::on_request(uint64 id, td_api::registerDevice &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.device_token_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Device token should not be empty");
|
||||
return send_error_raw(id, 400, "Device token must be non-empty");
|
||||
}
|
||||
CREATE_REQUEST_PROMISE();
|
||||
send_closure(device_token_manager_, &DeviceTokenManager::register_device, std::move(request.device_token_),
|
||||
@ -4795,7 +4795,7 @@ void Td::on_request(uint64 id, const td_api::getAccountTtl &request) {
|
||||
void Td::on_request(uint64 id, const td_api::setAccountTtl &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.ttl_ == nullptr) {
|
||||
return send_error_raw(id, 400, "New account TTL should not be empty");
|
||||
return send_error_raw(id, 400, "New account TTL must be non-empty");
|
||||
}
|
||||
CREATE_OK_REQUEST_PROMISE();
|
||||
contacts_manager_->set_account_ttl(request.ttl_->days_, std::move(promise));
|
||||
@ -4988,7 +4988,7 @@ void Td::on_request(uint64 id, td_api::optimizeStorage &request) {
|
||||
std::vector<FileType> file_types;
|
||||
for (auto &file_type : request.file_types_) {
|
||||
if (file_type == nullptr) {
|
||||
return send_error_raw(id, 400, "File type should not be empty");
|
||||
return send_error_raw(id, 400, "File type must be non-empty");
|
||||
}
|
||||
|
||||
file_types.push_back(from_td_api(*file_type));
|
||||
@ -5046,7 +5046,7 @@ void Td::on_request(uint64 id, td_api::resetNetworkStatistics &request) {
|
||||
|
||||
void Td::on_request(uint64 id, td_api::addNetworkStatistics &request) {
|
||||
if (request.entry_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Network statistics entry should not be empty");
|
||||
return send_error_raw(id, 400, "Network statistics entry must be non-empty");
|
||||
}
|
||||
|
||||
NetworkStatsEntry entry;
|
||||
@ -5121,7 +5121,7 @@ void Td::on_request(uint64 id, td_api::getTopChats &request) {
|
||||
CHECK_IS_USER();
|
||||
CREATE_REQUEST_PROMISE();
|
||||
if (request.category_ == nullptr) {
|
||||
return promise.set_error(Status::Error(400, "Top chat category should not be empty"));
|
||||
return promise.set_error(Status::Error(400, "Top chat category must be non-empty"));
|
||||
}
|
||||
if (request.limit_ <= 0) {
|
||||
return promise.set_error(Status::Error(400, "Limit must be positive"));
|
||||
@ -5141,7 +5141,7 @@ void Td::on_request(uint64 id, td_api::getTopChats &request) {
|
||||
void Td::on_request(uint64 id, const td_api::removeTopChat &request) {
|
||||
CHECK_IS_USER();
|
||||
if (request.category_ == nullptr) {
|
||||
return send_error_raw(id, 400, "Top chat category should not be empty");
|
||||
return send_error_raw(id, 400, "Top chat category must be non-empty");
|
||||
}
|
||||
|
||||
DialogId dialog_id(request.chat_id_);
|
||||
|
@ -12,10 +12,10 @@ namespace td {
|
||||
|
||||
Result<Proxy> Proxy::from_td_api(string server, int port, td_api::ProxyType *proxy_type) {
|
||||
if (proxy_type == nullptr) {
|
||||
return Status::Error(400, "Proxy type should not be empty");
|
||||
return Status::Error(400, "Proxy type must be non-empty");
|
||||
}
|
||||
if (server.empty()) {
|
||||
return Status::Error(400, "Server name can't be empty");
|
||||
return Status::Error(400, "Server name must be non-empty");
|
||||
}
|
||||
if (server.size() > 255) {
|
||||
return Status::Error(400, "Server name is too long");
|
||||
|
Loading…
Reference in New Issue
Block a user