Init some uninitialized Result variables.
GitOrigin-RevId: 48e15168e48d131c53a93a5c2971c7dadeeeb270
This commit is contained in:
parent
6810845770
commit
48740add28
@ -489,7 +489,7 @@ void InlineQueriesManager::answer_inline_query(int64 inline_query_id, bool is_pe
|
|||||||
int32 duration = 0;
|
int32 duration = 0;
|
||||||
|
|
||||||
FileType file_type = FileType::Temp;
|
FileType file_type = FileType::Temp;
|
||||||
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> r_inline_message;
|
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> r_inline_message = Status::Error(500, "Uninited");
|
||||||
switch (input_result->get_id()) {
|
switch (input_result->get_id()) {
|
||||||
case td_api::inputInlineQueryResultAnimatedGif::ID: {
|
case td_api::inputInlineQueryResultAnimatedGif::ID: {
|
||||||
auto animated_gif = move_tl_object_as<td_api::inputInlineQueryResultAnimatedGif>(input_result);
|
auto animated_gif = move_tl_object_as<td_api::inputInlineQueryResultAnimatedGif>(input_result);
|
||||||
|
@ -16427,7 +16427,7 @@ Result<MessagesManager::InputMessageContent> MessagesManager::process_input_mess
|
|||||||
|
|
||||||
bool have_file = true;
|
bool have_file = true;
|
||||||
// TODO: send from secret chat to common
|
// TODO: send from secret chat to common
|
||||||
Result<FileId> r_file_id;
|
Result<FileId> r_file_id = Status::Error(500, "Have no file");
|
||||||
tl_object_ptr<td_api::inputThumbnail> input_thumbnail;
|
tl_object_ptr<td_api::inputThumbnail> input_thumbnail;
|
||||||
vector<FileId> sticker_file_ids;
|
vector<FileId> sticker_file_ids;
|
||||||
switch (message_type) {
|
switch (message_type) {
|
||||||
|
@ -7178,18 +7178,17 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseTextEntiti
|
|||||||
return make_error(400, "Parse mode must be non-empty");
|
return make_error(400, "Parse mode must be non-empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<vector<MessageEntity>> r_entities;
|
auto r_entities = [&]() -> Result<vector<MessageEntity>> {
|
||||||
switch (request.parse_mode_->get_id()) {
|
switch (request.parse_mode_->get_id()) {
|
||||||
case td_api::textParseModeHTML::ID:
|
case td_api::textParseModeHTML::ID:
|
||||||
r_entities = parse_html(request.text_);
|
return parse_html(request.text_);
|
||||||
break;
|
case td_api::textParseModeMarkdown::ID:
|
||||||
case td_api::textParseModeMarkdown::ID:
|
return parse_markdown(request.text_);
|
||||||
r_entities = parse_markdown(request.text_);
|
default:
|
||||||
break;
|
UNREACHABLE();
|
||||||
default:
|
return Status::Error(500, "Unknown parse mode");
|
||||||
UNREACHABLE();
|
}
|
||||||
break;
|
}();
|
||||||
}
|
|
||||||
if (r_entities.is_error()) {
|
if (r_entities.is_error()) {
|
||||||
return make_error(400, PSLICE() << "Can't parse entities: " << r_entities.error().message());
|
return make_error(400, PSLICE() << "Can't parse entities: " << r_entities.error().message());
|
||||||
}
|
}
|
||||||
|
@ -275,12 +275,13 @@ Result<size_t> FileUploader::process_part(Part part, NetQueryPtr net_query) {
|
|||||||
if (net_query->is_error()) {
|
if (net_query->is_error()) {
|
||||||
return std::move(net_query->error());
|
return std::move(net_query->error());
|
||||||
}
|
}
|
||||||
Result<bool> result;
|
Result<bool> result = [&] {
|
||||||
if (big_flag_) {
|
if (big_flag_) {
|
||||||
result = fetch_result<telegram_api::upload_saveBigFilePart>(net_query->ok());
|
return fetch_result<telegram_api::upload_saveBigFilePart>(net_query->ok());
|
||||||
} else {
|
} else {
|
||||||
result = fetch_result<telegram_api::upload_saveFilePart>(net_query->ok());
|
return fetch_result<telegram_api::upload_saveFilePart>(net_query->ok());
|
||||||
}
|
}
|
||||||
|
}();
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
return result.move_as_error();
|
return result.move_as_error();
|
||||||
}
|
}
|
||||||
|
@ -517,7 +517,7 @@ class FutureActor final : public Actor {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EventFull event_;
|
EventFull event_;
|
||||||
Result<T> result_;
|
Result<T> result_ = Status::Error(500, "Empty FutureActor");
|
||||||
State state_;
|
State state_;
|
||||||
|
|
||||||
void set_value(T &&value) {
|
void set_value(T &&value) {
|
||||||
|
@ -23,6 +23,9 @@ class GetHostByNameActor final : public td::Actor {
|
|||||||
struct Value {
|
struct Value {
|
||||||
Result<td::IPAddress> ip;
|
Result<td::IPAddress> ip;
|
||||||
double expire_at;
|
double expire_at;
|
||||||
|
|
||||||
|
Value(Result<td::IPAddress> ip, double expire_at) : ip(std::move(ip)), expire_at(expire_at) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
std::unordered_map<string, Value> cache_;
|
std::unordered_map<string, Value> cache_;
|
||||||
static constexpr int32 CACHE_TIME = 60 * 29; // 29 minutes
|
static constexpr int32 CACHE_TIME = 60 * 29; // 29 minutes
|
||||||
|
@ -610,19 +610,20 @@ Status HttpReader::parse_json_parameters(MutableSlice parameters) {
|
|||||||
return Status::Error(400, "Bad Request: can't parse object, ':' expected");
|
return Status::Error(400, "Bad Request: can't parse object, ':' expected");
|
||||||
}
|
}
|
||||||
parser.skip_whitespaces();
|
parser.skip_whitespaces();
|
||||||
Result<MutableSlice> r_value;
|
auto r_value = [&]() -> Result<MutableSlice> {
|
||||||
if (parser.peek_char() == '"') {
|
if (parser.peek_char() == '"') {
|
||||||
r_value = json_string_decode(parser);
|
return json_string_decode(parser);
|
||||||
} else {
|
|
||||||
const int32 DEFAULT_MAX_DEPTH = 100;
|
|
||||||
auto begin = parser.ptr();
|
|
||||||
auto result = do_json_skip(parser, DEFAULT_MAX_DEPTH);
|
|
||||||
if (result.is_ok()) {
|
|
||||||
r_value = MutableSlice(begin, parser.ptr());
|
|
||||||
} else {
|
} else {
|
||||||
r_value = result.move_as_error();
|
const int32 DEFAULT_MAX_DEPTH = 100;
|
||||||
|
auto begin = parser.ptr();
|
||||||
|
auto result = do_json_skip(parser, DEFAULT_MAX_DEPTH);
|
||||||
|
if (result.is_ok()) {
|
||||||
|
return MutableSlice(begin, parser.ptr());
|
||||||
|
} else {
|
||||||
|
return result.move_as_error();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}();
|
||||||
if (r_value.is_error()) {
|
if (r_value.is_error()) {
|
||||||
return Status::Error(400,
|
return Status::Error(400,
|
||||||
string("Bad Request: can't parse parameter value: ") + r_value.error().message().c_str());
|
string("Bad Request: can't parse parameter value: ") + r_value.error().message().c_str());
|
||||||
|
Reference in New Issue
Block a user