-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathrpc_req_error.cpp
More file actions
80 lines (74 loc) · 2.19 KB
/
rpc_req_error.cpp
File metadata and controls
80 lines (74 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Compiler for PHP (aka KPHP)
// Copyright (c) 2023 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt
#include "runtime/tl/rpc_req_error.h"
#include "common/rpc-error-codes.h"
#include "common/tl/constants/common.h"
#include "runtime/rpc.h"
bool RpcError::try_fetch() noexcept {
int pos_backup = rpc_get_pos();
int op = tl_parse_int();
if (op == TL_REQ_RESULT_HEADER) {
int flags = tl_parse_int();
fetch_and_skip_header(flags);
op = tl_parse_int();
}
if (op != TL_RPC_REQ_ERROR) {
rpc_set_pos(pos_backup);
return false;
}
tl_parse_long();
error_code = tl_parse_int();
error_msg = tl_parse_string();
if (!CurException.is_null()) {
error_code = TL_ERROR_SYNTAX;
error_msg = std::move(CurException->$message);
CurException = Optional<bool>{};
}
return true;
}
void RpcError::fetch_and_skip_header(int flags) const noexcept {
if (flags & vk::tl::common::rpc_req_result_extra_flags::binlog_pos) {
tl_parse_long();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::binlog_time) {
tl_parse_long();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::engine_pid) {
tl_parse_int();
tl_parse_int();
tl_parse_int();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::request_size) {
tl_parse_int();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::response_size) {
tl_parse_int();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::failed_subqueries) {
tl_parse_int();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::compression_version) {
tl_parse_int();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::stats) {
auto n{tl_parse_int()};
for (auto i{0}; i < n; ++i) {
tl_parse_string();
tl_parse_string();
}
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::shards_binlog_pos) {
auto n{tl_parse_int()};
for (auto i{0}; i < n; ++i) {
tl_parse_string();
tl_parse_long();
}
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::epoch_number) {
tl_parse_long();
}
if (flags & vk::tl::common::rpc_req_result_extra_flags::view_number) {
tl_parse_long();
}
}