/root/doris/be/src/common/status.h
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2011 The LevelDB Authors. All rights reserved. |
2 | | // Use of this source code is governed by a BSD-style license that can be |
3 | | // found in the LICENSE file. See the AUTHORS file for names of contributors. |
4 | | |
5 | | #pragma once |
6 | | |
7 | | #include <fmt/format.h> |
8 | | #include <gen_cpp/Status_types.h> // for TStatus |
9 | | #include <gen_cpp/types.pb.h> |
10 | | #include <glog/logging.h> |
11 | | #include <stdint.h> |
12 | | |
13 | | #include <iostream> |
14 | | #include <memory> |
15 | | #include <string> |
16 | | #include <string_view> |
17 | | #include <utility> |
18 | | |
19 | | // IWYU pragma: no_include <opentelemetry/common/threadlocal.h> |
20 | | #include "common/compiler_util.h" // IWYU pragma: keep |
21 | | #ifdef ENABLE_STACKTRACE |
22 | | #include "util/stack_util.h" |
23 | | #endif |
24 | | |
25 | | #include "common/expected.h" |
26 | | |
27 | | namespace doris { |
28 | | |
29 | | class PStatus; |
30 | | |
31 | | namespace ErrorCode { |
32 | | #define E(name, code) static constexpr int name = code |
33 | | E(OK, 0); |
34 | | #define TStatusError(name) E(name, TStatusCode::name) |
35 | | // Errors defined in TStatus |
36 | | TStatusError(PUBLISH_TIMEOUT); |
37 | | TStatusError(MEM_ALLOC_FAILED); |
38 | | TStatusError(BUFFER_ALLOCATION_FAILED); |
39 | | TStatusError(INVALID_ARGUMENT); |
40 | | TStatusError(INVALID_DATA_FORMAT); |
41 | | TStatusError(INVALID_JSON_PATH); |
42 | | TStatusError(MINIMUM_RESERVATION_UNAVAILABLE); |
43 | | TStatusError(CORRUPTION); |
44 | | TStatusError(IO_ERROR); |
45 | | TStatusError(NOT_FOUND); |
46 | | TStatusError(ALREADY_EXIST); |
47 | | TStatusError(NOT_IMPLEMENTED_ERROR); |
48 | | TStatusError(END_OF_FILE); |
49 | | TStatusError(INTERNAL_ERROR); |
50 | | TStatusError(RUNTIME_ERROR); |
51 | | TStatusError(CANCELLED); |
52 | | TStatusError(MEM_LIMIT_EXCEEDED); |
53 | | TStatusError(THRIFT_RPC_ERROR); |
54 | | TStatusError(TIMEOUT); |
55 | | TStatusError(TOO_MANY_TASKS); |
56 | | TStatusError(UNINITIALIZED); |
57 | | TStatusError(ABORTED); |
58 | | TStatusError(DATA_QUALITY_ERROR); |
59 | | TStatusError(LABEL_ALREADY_EXISTS); |
60 | | TStatusError(NOT_AUTHORIZED); |
61 | | TStatusError(HTTP_ERROR); |
62 | | #undef TStatusError |
63 | | // BE internal errors |
64 | | E(OS_ERROR, -100); |
65 | | E(DIR_NOT_EXIST, -101); |
66 | | E(FILE_NOT_EXIST, -102); |
67 | | E(CREATE_FILE_ERROR, -103); |
68 | | E(STL_ERROR, -105); |
69 | | E(MUTEX_ERROR, -107); |
70 | | E(PTHREAD_ERROR, -108); |
71 | | E(NETWORK_ERROR, -109); |
72 | | E(UB_FUNC_ERROR, -110); |
73 | | E(COMPRESS_ERROR, -111); |
74 | | E(DECOMPRESS_ERROR, -112); |
75 | | E(UNKNOWN_COMPRESSION_TYPE, -113); |
76 | | E(MMAP_ERROR, -114); |
77 | | E(READ_UNENOUGH, -116); |
78 | | E(CANNOT_CREATE_DIR, -117); |
79 | | E(UB_NETWORK_ERROR, -118); |
80 | | E(FILE_FORMAT_ERROR, -119); |
81 | | E(EVAL_CONJUNCTS_ERROR, -120); |
82 | | E(COPY_FILE_ERROR, -121); |
83 | | E(FILE_ALREADY_EXIST, -122); |
84 | | E(BAD_CAST, -123); |
85 | | E(ARITHMETIC_OVERFLOW_ERRROR, -124); |
86 | | E(PERMISSION_DENIED, -125); |
87 | | E(CALL_SEQUENCE_ERROR, -202); |
88 | | E(BUFFER_OVERFLOW, -204); |
89 | | E(CONFIG_ERROR, -205); |
90 | | E(INIT_FAILED, -206); |
91 | | E(INVALID_SCHEMA, -207); |
92 | | E(CHECKSUM_ERROR, -208); |
93 | | E(SIGNATURE_ERROR, -209); |
94 | | E(CATCH_EXCEPTION, -210); |
95 | | E(PARSE_PROTOBUF_ERROR, -211); |
96 | | E(SERIALIZE_PROTOBUF_ERROR, -212); |
97 | | E(WRITE_PROTOBUF_ERROR, -213); |
98 | | E(VERSION_NOT_EXIST, -214); |
99 | | E(TABLE_NOT_FOUND, -215); |
100 | | E(TRY_LOCK_FAILED, -216); |
101 | | E(OUT_OF_BOUND, -218); |
102 | | E(FILE_DATA_ERROR, -220); |
103 | | E(TEST_FILE_ERROR, -221); |
104 | | E(INVALID_ROOT_PATH, -222); |
105 | | E(NO_AVAILABLE_ROOT_PATH, -223); |
106 | | E(CHECK_LINES_ERROR, -224); |
107 | | E(INVALID_CLUSTER_INFO, -225); |
108 | | E(TRANSACTION_NOT_EXIST, -226); |
109 | | E(DISK_FAILURE, -227); |
110 | | E(TRANSACTION_ALREADY_COMMITTED, -228); |
111 | | E(TRANSACTION_ALREADY_VISIBLE, -229); |
112 | | E(VERSION_ALREADY_MERGED, -230); |
113 | | E(LZO_DISABLED, -231); |
114 | | E(DISK_REACH_CAPACITY_LIMIT, -232); |
115 | | E(TOO_MANY_TRANSACTIONS, -233); |
116 | | E(INVALID_SNAPSHOT_VERSION, -234); |
117 | | E(TOO_MANY_VERSION, -235); |
118 | | E(NOT_INITIALIZED, -236); |
119 | | E(ALREADY_CANCELLED, -237); |
120 | | E(TOO_MANY_SEGMENTS, -238); |
121 | | E(ALREADY_CLOSED, -239); |
122 | | E(SERVICE_UNAVAILABLE, -240); |
123 | | E(CE_CMD_PARAMS_ERROR, -300); |
124 | | E(CE_BUFFER_TOO_SMALL, -301); |
125 | | E(CE_CMD_NOT_VALID, -302); |
126 | | E(CE_LOAD_TABLE_ERROR, -303); |
127 | | E(CE_NOT_FINISHED, -304); |
128 | | E(CE_TABLET_ID_EXIST, -305); |
129 | | E(TABLE_VERSION_DUPLICATE_ERROR, -400); |
130 | | E(TABLE_VERSION_INDEX_MISMATCH_ERROR, -401); |
131 | | E(TABLE_INDEX_VALIDATE_ERROR, -402); |
132 | | E(TABLE_INDEX_FIND_ERROR, -403); |
133 | | E(TABLE_CREATE_FROM_HEADER_ERROR, -404); |
134 | | E(TABLE_CREATE_META_ERROR, -405); |
135 | | E(TABLE_ALREADY_DELETED_ERROR, -406); |
136 | | E(ENGINE_INSERT_EXISTS_TABLE, -500); |
137 | | E(ENGINE_DROP_NOEXISTS_TABLE, -501); |
138 | | E(ENGINE_LOAD_INDEX_TABLE_ERROR, -502); |
139 | | E(TABLE_INSERT_DUPLICATION_ERROR, -503); |
140 | | E(DELETE_VERSION_ERROR, -504); |
141 | | E(GC_SCAN_PATH_ERROR, -505); |
142 | | E(ENGINE_INSERT_OLD_TABLET, -506); |
143 | | E(FETCH_OTHER_ERROR, -600); |
144 | | E(FETCH_TABLE_NOT_EXIST, -601); |
145 | | E(FETCH_VERSION_ERROR, -602); |
146 | | E(FETCH_SCHEMA_ERROR, -603); |
147 | | E(FETCH_COMPRESSION_ERROR, -604); |
148 | | E(FETCH_CONTEXT_NOT_EXIST, -605); |
149 | | E(FETCH_GET_READER_PARAMS_ERR, -606); |
150 | | E(FETCH_SAVE_SESSION_ERR, -607); |
151 | | E(FETCH_MEMORY_EXCEEDED, -608); |
152 | | E(READER_IS_UNINITIALIZED, -700); |
153 | | E(READER_GET_ITERATOR_ERROR, -701); |
154 | | E(CAPTURE_ROWSET_READER_ERROR, -702); |
155 | | E(READER_READING_ERROR, -703); |
156 | | E(READER_INITIALIZE_ERROR, -704); |
157 | | E(BE_VERSION_NOT_MATCH, -800); |
158 | | E(BE_REPLACE_VERSIONS_ERROR, -801); |
159 | | E(BE_MERGE_ERROR, -802); |
160 | | E(CAPTURE_ROWSET_ERROR, -804); |
161 | | E(BE_SAVE_HEADER_ERROR, -805); |
162 | | E(BE_INIT_OLAP_DATA, -806); |
163 | | E(BE_TRY_OBTAIN_VERSION_LOCKS, -807); |
164 | | E(BE_NO_SUITABLE_VERSION, -808); |
165 | | E(BE_INVALID_NEED_MERGED_VERSIONS, -810); |
166 | | E(BE_ERROR_DELETE_ACTION, -811); |
167 | | E(BE_SEGMENTS_OVERLAPPING, -812); |
168 | | E(PUSH_INIT_ERROR, -900); |
169 | | E(PUSH_VERSION_INCORRECT, -902); |
170 | | E(PUSH_SCHEMA_MISMATCH, -903); |
171 | | E(PUSH_CHECKSUM_ERROR, -904); |
172 | | E(PUSH_ACQUIRE_DATASOURCE_ERROR, -905); |
173 | | E(PUSH_CREAT_CUMULATIVE_ERROR, -906); |
174 | | E(PUSH_BUILD_DELTA_ERROR, -907); |
175 | | E(PUSH_VERSION_ALREADY_EXIST, -908); |
176 | | E(PUSH_TABLE_NOT_EXIST, -909); |
177 | | E(PUSH_INPUT_DATA_ERROR, -910); |
178 | | E(PUSH_TRANSACTION_ALREADY_EXIST, -911); |
179 | | E(PUSH_BATCH_PROCESS_REMOVED, -912); |
180 | | E(PUSH_COMMIT_ROWSET, -913); |
181 | | E(PUSH_ROWSET_NOT_FOUND, -914); |
182 | | E(INDEX_LOAD_ERROR, -1000); |
183 | | E(INDEX_CHECKSUM_ERROR, -1002); |
184 | | E(INDEX_DELTA_PRUNING, -1003); |
185 | | E(DATA_ROW_BLOCK_ERROR, -1100); |
186 | | E(DATA_FILE_TYPE_ERROR, -1101); |
187 | | E(WRITER_INDEX_WRITE_ERROR, -1200); |
188 | | E(WRITER_DATA_WRITE_ERROR, -1201); |
189 | | E(WRITER_ROW_BLOCK_ERROR, -1202); |
190 | | E(WRITER_SEGMENT_NOT_FINALIZED, -1203); |
191 | | E(ROWBLOCK_DECOMPRESS_ERROR, -1300); |
192 | | E(ROWBLOCK_FIND_ROW_EXCEPTION, -1301); |
193 | | E(HEADER_ADD_VERSION, -1400); |
194 | | E(HEADER_DELETE_VERSION, -1401); |
195 | | E(HEADER_ADD_PENDING_DELTA, -1402); |
196 | | E(HEADER_ADD_INCREMENTAL_VERSION, -1403); |
197 | | E(HEADER_INVALID_FLAG, -1404); |
198 | | E(HEADER_LOAD_INVALID_KEY, -1408); |
199 | | E(HEADER_LOAD_JSON_HEADER, -1410); |
200 | | E(HEADER_INIT_FAILED, -1411); |
201 | | E(HEADER_PB_PARSE_FAILED, -1412); |
202 | | E(HEADER_HAS_PENDING_DATA, -1413); |
203 | | E(SCHEMA_SCHEMA_INVALID, -1500); |
204 | | E(SCHEMA_SCHEMA_FIELD_INVALID, -1501); |
205 | | E(ALTER_MULTI_TABLE_ERR, -1600); |
206 | | E(ALTER_DELTA_DOES_NOT_EXISTS, -1601); |
207 | | E(ALTER_STATUS_ERR, -1602); |
208 | | E(PREVIOUS_SCHEMA_CHANGE_NOT_FINISHED, -1603); |
209 | | E(SCHEMA_CHANGE_INFO_INVALID, -1604); |
210 | | E(QUERY_SPLIT_KEY_ERR, -1605); |
211 | | E(DATA_QUALITY_ERR, -1606); |
212 | | E(COLUMN_DATA_LOAD_BLOCK, -1700); |
213 | | E(COLUMN_DATA_RECORD_INDEX, -1701); |
214 | | E(COLUMN_DATA_MAKE_FILE_HEADER, -1702); |
215 | | E(COLUMN_DATA_READ_VAR_INT, -1703); |
216 | | E(COLUMN_DATA_PATCH_LIST_NUM, -1704); |
217 | | E(COLUMN_READ_STREAM, -1706); |
218 | | E(COLUMN_STREAM_NOT_EXIST, -1716); |
219 | | E(COLUMN_VALUE_NULL, -1717); |
220 | | E(COLUMN_SEEK_ERROR, -1719); |
221 | | E(COLUMN_NO_MATCH_OFFSETS_SIZE, -1720); |
222 | | E(COLUMN_NO_MATCH_FILTER_SIZE, -1721); |
223 | | E(DELETE_INVALID_CONDITION, -1900); |
224 | | E(DELETE_UPDATE_HEADER_FAILED, -1901); |
225 | | E(DELETE_SAVE_HEADER_FAILED, -1902); |
226 | | E(DELETE_INVALID_PARAMETERS, -1903); |
227 | | E(DELETE_INVALID_VERSION, -1904); |
228 | | E(CUMULATIVE_NO_SUITABLE_VERSION, -2000); |
229 | | E(CUMULATIVE_REPEAT_INIT, -2001); |
230 | | E(CUMULATIVE_INVALID_PARAMETERS, -2002); |
231 | | E(CUMULATIVE_FAILED_ACQUIRE_DATA_SOURCE, -2003); |
232 | | E(CUMULATIVE_INVALID_NEED_MERGED_VERSIONS, -2004); |
233 | | E(CUMULATIVE_ERROR_DELETE_ACTION, -2005); |
234 | | E(CUMULATIVE_MISS_VERSION, -2006); |
235 | | E(FULL_NO_SUITABLE_VERSION, -2008); |
236 | | E(FULL_MISS_VERSION, -2009); |
237 | | E(META_INVALID_ARGUMENT, -3000); |
238 | | E(META_OPEN_DB_ERROR, -3001); |
239 | | E(META_KEY_NOT_FOUND, -3002); |
240 | | E(META_GET_ERROR, -3003); |
241 | | E(META_PUT_ERROR, -3004); |
242 | | E(META_ITERATOR_ERROR, -3005); |
243 | | E(META_DELETE_ERROR, -3006); |
244 | | E(META_ALREADY_EXIST, -3007); |
245 | | E(ROWSET_WRITER_INIT, -3100); |
246 | | E(ROWSET_SAVE_FAILED, -3101); |
247 | | E(ROWSET_GENERATE_ID_FAILED, -3102); |
248 | | E(ROWSET_DELETE_FILE_FAILED, -3103); |
249 | | E(ROWSET_BUILDER_INIT, -3104); |
250 | | E(ROWSET_TYPE_NOT_FOUND, -3105); |
251 | | E(ROWSET_ALREADY_EXIST, -3106); |
252 | | E(ROWSET_CREATE_READER, -3107); |
253 | | E(ROWSET_INVALID, -3108); |
254 | | E(ROWSET_READER_INIT, -3110); |
255 | | E(ROWSET_INVALID_STATE_TRANSITION, -3112); |
256 | | E(STRING_OVERFLOW_IN_VEC_ENGINE, -3113); |
257 | | E(ROWSET_ADD_MIGRATION_V2, -3114); |
258 | | E(PUBLISH_VERSION_NOT_CONTINUOUS, -3115); |
259 | | E(ROWSET_RENAME_FILE_FAILED, -3116); |
260 | | E(SEGCOMPACTION_INIT_READER, -3117); |
261 | | E(SEGCOMPACTION_INIT_WRITER, -3118); |
262 | | E(SEGCOMPACTION_FAILED, -3119); |
263 | | E(PIP_WAIT_FOR_RF, -3120); |
264 | | E(PIP_WAIT_FOR_SC, -3121); |
265 | | E(ROWSET_ADD_TO_BINLOG_FAILED, -3122); |
266 | | E(ROWSET_BINLOG_NOT_ONLY_ONE_VERSION, -3123); |
267 | | E(INVERTED_INDEX_INVALID_PARAMETERS, -6000); |
268 | | E(INVERTED_INDEX_NOT_SUPPORTED, -6001); |
269 | | E(INVERTED_INDEX_CLUCENE_ERROR, -6002); |
270 | | E(INVERTED_INDEX_FILE_NOT_FOUND, -6003); |
271 | | E(INVERTED_INDEX_BYPASS, -6004); |
272 | | E(INVERTED_INDEX_NO_TERMS, -6005); |
273 | | E(INVERTED_INDEX_RENAME_FILE_FAILED, -6006); |
274 | | E(INVERTED_INDEX_EVALUATE_SKIPPED, -6007); |
275 | | E(INVERTED_INDEX_BUILD_WAITTING, -6008); |
276 | | E(INVERTED_INDEX_NOT_IMPLEMENTED, -6009); |
277 | | E(INVERTED_INDEX_COMPACTION_ERROR, -6010); |
278 | | E(INVERTED_INDEX_ANALYZER_ERROR, -6011); |
279 | | E(KEY_NOT_FOUND, -7000); |
280 | | E(KEY_ALREADY_EXISTS, -7001); |
281 | | E(ENTRY_NOT_FOUND, -7002); |
282 | | #undef E |
283 | | } // namespace ErrorCode |
284 | | |
285 | | // clang-format off |
286 | | // whether to capture stacktrace |
287 | 0 | constexpr bool capture_stacktrace(int code) { |
288 | 0 | return code != ErrorCode::OK |
289 | 0 | && code != ErrorCode::END_OF_FILE |
290 | 0 | && code != ErrorCode::DATA_QUALITY_ERROR |
291 | 0 | && code != ErrorCode::MEM_LIMIT_EXCEEDED |
292 | 0 | && code != ErrorCode::TRY_LOCK_FAILED |
293 | 0 | && code != ErrorCode::TOO_MANY_SEGMENTS |
294 | 0 | && code != ErrorCode::TOO_MANY_VERSION |
295 | 0 | && code != ErrorCode::ALREADY_CANCELLED |
296 | 0 | && code != ErrorCode::ALREADY_CLOSED |
297 | 0 | && code != ErrorCode::PUSH_TRANSACTION_ALREADY_EXIST |
298 | 0 | && code != ErrorCode::BE_NO_SUITABLE_VERSION |
299 | 0 | && code != ErrorCode::CUMULATIVE_NO_SUITABLE_VERSION |
300 | 0 | && code != ErrorCode::FULL_NO_SUITABLE_VERSION |
301 | 0 | && code != ErrorCode::PUBLISH_VERSION_NOT_CONTINUOUS |
302 | 0 | && code != ErrorCode::PUBLISH_TIMEOUT |
303 | 0 | && code != ErrorCode::ROWSET_RENAME_FILE_FAILED |
304 | 0 | && code != ErrorCode::SEGCOMPACTION_INIT_READER |
305 | 0 | && code != ErrorCode::SEGCOMPACTION_INIT_WRITER |
306 | 0 | && code != ErrorCode::SEGCOMPACTION_FAILED |
307 | 0 | && code != ErrorCode::INVALID_ARGUMENT |
308 | 0 | && code != ErrorCode::INVERTED_INDEX_INVALID_PARAMETERS |
309 | 0 | && code != ErrorCode::INVERTED_INDEX_NOT_SUPPORTED |
310 | 0 | && code != ErrorCode::INVERTED_INDEX_CLUCENE_ERROR |
311 | 0 | && code != ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND |
312 | 0 | && code != ErrorCode::INVERTED_INDEX_BYPASS |
313 | 0 | && code != ErrorCode::INVERTED_INDEX_NO_TERMS |
314 | 0 | && code != ErrorCode::INVERTED_INDEX_EVALUATE_SKIPPED |
315 | 0 | && code != ErrorCode::INVERTED_INDEX_BUILD_WAITTING |
316 | 0 | && code != ErrorCode::INVERTED_INDEX_NOT_IMPLEMENTED |
317 | 0 | && code != ErrorCode::META_KEY_NOT_FOUND |
318 | 0 | && code != ErrorCode::PUSH_VERSION_ALREADY_EXIST |
319 | 0 | && code != ErrorCode::VERSION_NOT_EXIST |
320 | 0 | && code != ErrorCode::TABLE_ALREADY_DELETED_ERROR |
321 | 0 | && code != ErrorCode::TRANSACTION_NOT_EXIST |
322 | 0 | && code != ErrorCode::TRANSACTION_ALREADY_VISIBLE |
323 | 0 | && code != ErrorCode::TOO_MANY_TRANSACTIONS |
324 | 0 | && code != ErrorCode::TRANSACTION_ALREADY_COMMITTED |
325 | 0 | && code != ErrorCode::ENTRY_NOT_FOUND |
326 | 0 | && code != ErrorCode::KEY_NOT_FOUND |
327 | 0 | && code != ErrorCode::KEY_ALREADY_EXISTS |
328 | 0 | && code != ErrorCode::CANCELLED |
329 | 0 | && code != ErrorCode::UNINITIALIZED |
330 | 0 | && code != ErrorCode::PIP_WAIT_FOR_RF |
331 | 0 | && code != ErrorCode::PIP_WAIT_FOR_SC |
332 | 0 | && code != ErrorCode::INVALID_DATA_FORMAT; |
333 | 0 | } |
334 | | // clang-format on |
335 | | |
336 | | class Status { |
337 | | public: |
338 | 35.1M | Status() : _code(ErrorCode::OK), _err_msg(nullptr) {} |
339 | | |
340 | | // copy c'tor makes copy of error detail so Status can be returned by value |
341 | 157k | Status(const Status& rhs) { *this = rhs; } |
342 | | |
343 | | // move c'tor |
344 | 1.05k | Status(Status&& rhs) noexcept = default; |
345 | | |
346 | | // same as copy c'tor |
347 | 157k | Status& operator=(const Status& rhs) { |
348 | 157k | _code = rhs._code; |
349 | 157k | if (rhs._err_msg) { |
350 | 18 | _err_msg = std::make_unique<ErrMsg>(*rhs._err_msg); |
351 | 18 | } |
352 | 157k | return *this; |
353 | 157k | } |
354 | | |
355 | | // move assign |
356 | 2.45M | Status& operator=(Status&& rhs) noexcept { |
357 | 2.45M | _code = rhs._code; |
358 | 2.45M | if (rhs._err_msg) { |
359 | 658 | _err_msg = std::move(rhs._err_msg); |
360 | 658 | } |
361 | 2.45M | return *this; |
362 | 2.45M | } |
363 | | |
364 | | template <bool stacktrace = true> |
365 | | Status static create(const TStatus& status) { |
366 | | return Error<stacktrace>( |
367 | | status.status_code, |
368 | | "TStatus: " + (status.error_msgs.empty() ? "" : status.error_msgs[0])); |
369 | | } |
370 | | |
371 | | template <bool stacktrace = true> |
372 | | Status static create(const PStatus& pstatus) { |
373 | | return Error<stacktrace>( |
374 | | pstatus.status_code(), |
375 | | "PStatus: " + (pstatus.error_msgs_size() == 0 ? "" : pstatus.error_msgs(0))); |
376 | | } |
377 | | |
378 | | template <int code, bool stacktrace = true, typename... Args> |
379 | 3.02k | Status static Error(std::string_view msg, Args&&... args) { |
380 | 3.02k | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); |
381 | 3.02k | } _ZN5doris6Status5ErrorILi6ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Line | Count | Source | 379 | 8 | Status static Error(std::string_view msg, Args&&... args) { | 380 | 8 | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 8 | } |
_ZN5doris6Status5ErrorILi33ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Line | Count | Source | 379 | 37 | Status static Error(std::string_view msg, Args&&... args) { | 380 | 37 | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 37 | } |
_ZN5doris6Status5ErrorILi4ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Line | Count | Source | 379 | 7 | Status static Error(std::string_view msg, Args&&... args) { | 380 | 7 | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 7 | } |
_ZN5doris6Status5ErrorILi3ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Line | Count | Source | 379 | 1 | Status static Error(std::string_view msg, Args&&... args) { | 380 | 1 | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 1 | } |
Unexecuted instantiation: _ZN5doris6Status5ErrorILi33ELb1EJRmRKtEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi33ELb1EJRNS_10segment_v214HashStrategyPBEEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILin6009ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi6ELb1EJR8CURLcodeEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi33ELb1EJNS_13PredicateTypeEEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ _ZN5doris6Status5ErrorILin3002ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Line | Count | Source | 379 | 8 | Status static Error(std::string_view msg, Args&&... args) { | 380 | 8 | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 8 | } |
_ZN5doris6Status5ErrorILi33ELb1EJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEES0_St17basic_string_viewIcS5_EDpOT1_ Line | Count | Source | 379 | 7 | Status static Error(std::string_view msg, Args&&... args) { | 380 | 7 | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 7 | } |
_ZN5doris6Status5ErrorILi30ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Line | Count | Source | 379 | 2.95k | Status static Error(std::string_view msg, Args&&... args) { | 380 | 2.95k | return Error<stacktrace>(code, msg, std::forward<Args>(args)...); | 381 | 2.95k | } |
Unexecuted instantiation: _ZN5doris6Status5ErrorILin6010ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi6ELb1EJiiEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi6ELb1EJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EEES0_St17basic_string_viewIcS5_EDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi6ELb1EJiiiiEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi12ELb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi6ELb1EJRmNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmEEES0_St17basic_string_viewIcS6_EDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi32ELb1EJRmS2_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EEES0_St17basic_string_viewIcS6_EDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi32ELb1EJRjRmEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ Unexecuted instantiation: _ZN5doris6Status5ErrorILi6ELb1EJPKcEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT1_ |
382 | | |
383 | | template <bool stacktrace = true, typename... Args> |
384 | 3.49k | Status static Error(int code, std::string_view msg, Args&&... args) { |
385 | 3.49k | Status status; |
386 | 3.49k | status._code = code; |
387 | 3.49k | status._err_msg = std::make_unique<ErrMsg>(); |
388 | 3.49k | if constexpr (sizeof...(args) == 0) { |
389 | 161 | status._err_msg->_msg = msg; |
390 | 161 | } else { |
391 | 161 | status._err_msg->_msg = fmt::format(msg, std::forward<Args>(args)...); |
392 | 161 | } |
393 | | #ifdef ENABLE_STACKTRACE |
394 | | if (stacktrace && capture_stacktrace(code)) { |
395 | | status._err_msg->_stack = get_stack_trace(1); |
396 | | LOG(WARNING) << "meet error status: " << status; // may print too many stacks. |
397 | | } |
398 | | #endif |
399 | 3.49k | return status; |
400 | 3.49k | } _ZN5doris6Status5ErrorILb1EJEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Line | Count | Source | 384 | 3.32k | Status static Error(int code, std::string_view msg, Args&&... args) { | 385 | 3.32k | Status status; | 386 | 3.32k | status._code = code; | 387 | 3.32k | status._err_msg = std::make_unique<ErrMsg>(); | 388 | 3.32k | if constexpr (sizeof...(args) == 0) { | 389 | 3.32k | status._err_msg->_msg = msg; | 390 | 3.32k | } else { | 391 | 3.32k | status._err_msg->_msg = fmt::format(msg, std::forward<Args>(args)...); | 392 | 3.32k | } | 393 | | #ifdef ENABLE_STACKTRACE | 394 | | if (stacktrace && capture_stacktrace(code)) { | 395 | | status._err_msg->_stack = get_stack_trace(1); | 396 | | LOG(WARNING) << "meet error status: " << status; // may print too many stacks. | 397 | | } | 398 | | #endif | 399 | 3.32k | return status; | 400 | 3.32k | } |
Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJRmRKtEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJRNS_10segment_v214HashStrategyPBEEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJR8CURLcodeEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJNS_13PredicateTypeEEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ _ZN5doris6Status5ErrorILb1EJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEEES0_iSt17basic_string_viewIcS5_EDpOT0_ Line | Count | Source | 384 | 21 | Status static Error(int code, std::string_view msg, Args&&... args) { | 385 | 21 | Status status; | 386 | 21 | status._code = code; | 387 | 21 | status._err_msg = std::make_unique<ErrMsg>(); | 388 | 21 | if constexpr (sizeof...(args) == 0) { | 389 | 21 | status._err_msg->_msg = msg; | 390 | 21 | } else { | 391 | 21 | status._err_msg->_msg = fmt::format(msg, std::forward<Args>(args)...); | 392 | 21 | } | 393 | | #ifdef ENABLE_STACKTRACE | 394 | | if (stacktrace && capture_stacktrace(code)) { | 395 | | status._err_msg->_stack = get_stack_trace(1); | 396 | | LOG(WARNING) << "meet error status: " << status; // may print too many stacks. | 397 | | } | 398 | | #endif | 399 | 21 | return status; | 400 | 21 | } |
Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJiiEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EEES0_iSt17basic_string_viewIcS5_EDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJiiiiEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJRmNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmEEES0_iSt17basic_string_viewIcS6_EDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJRmS2_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EEES0_iSt17basic_string_viewIcS6_EDpOT0_ Unexecuted instantiation: _ZN5doris6Status5ErrorILb1EJRjRmEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ _ZN5doris6Status5ErrorILb1EJPKcEEES0_iSt17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Line | Count | Source | 384 | 140 | Status static Error(int code, std::string_view msg, Args&&... args) { | 385 | 140 | Status status; | 386 | 140 | status._code = code; | 387 | 140 | status._err_msg = std::make_unique<ErrMsg>(); | 388 | 140 | if constexpr (sizeof...(args) == 0) { | 389 | 140 | status._err_msg->_msg = msg; | 390 | 140 | } else { | 391 | 140 | status._err_msg->_msg = fmt::format(msg, std::forward<Args>(args)...); | 392 | 140 | } | 393 | | #ifdef ENABLE_STACKTRACE | 394 | | if (stacktrace && capture_stacktrace(code)) { | 395 | | status._err_msg->_stack = get_stack_trace(1); | 396 | | LOG(WARNING) << "meet error status: " << status; // may print too many stacks. | 397 | | } | 398 | | #endif | 399 | 140 | return status; | 400 | 140 | } |
|
401 | | |
402 | 34.9M | static Status OK() { return Status(); } |
403 | | |
404 | | #define ERROR_CTOR(name, code) \ |
405 | | template <bool stacktrace = true, typename... Args> \ |
406 | 2.71k | static Status name(std::string_view msg, Args&&... args) { \ |
407 | 2.71k | return Error<ErrorCode::code, stacktrace>(msg, std::forward<Args>(args)...); \ |
408 | 2.71k | } _ZN5doris6Status13InternalErrorILb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Line | Count | Source | 406 | 8 | static Status name(std::string_view msg, Args&&... args) { \ | 407 | 8 | return Error<ErrorCode::code, stacktrace>(msg, std::forward<Args>(args)...); \ | 408 | 8 | } |
_ZN5doris6Status12RuntimeErrorILb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Line | Count | Source | 406 | 7 | static Status name(std::string_view msg, Args&&... args) { \ | 407 | 7 | return Error<ErrorCode::code, stacktrace>(msg, std::forward<Args>(args)...); \ | 408 | 7 | } |
_ZN5doris6Status12NotSupportedILb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Line | Count | Source | 406 | 1 | static Status name(std::string_view msg, Args&&... args) { \ | 407 | 1 | return Error<ErrorCode::code, stacktrace>(msg, std::forward<Args>(args)...); \ | 408 | 1 | } |
Unexecuted instantiation: _ZN5doris6Status15InvalidArgumentILb1EJRNS_10segment_v214HashStrategyPBEEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status13InternalErrorILb1EJR8CURLcodeEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status15InvalidArgumentILb1EJNS_13PredicateTypeEEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status13InternalErrorILb1EJiiEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status13InternalErrorILb1EJRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EEES0_St17basic_string_viewIcS5_EDpOT0_ Unexecuted instantiation: _ZN5doris6Status13InternalErrorILb1EJiiiiEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status17BufferAllocFailedILb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status13InternalErrorILb1EJRmNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEmEEES0_St17basic_string_viewIcS6_EDpOT0_ Unexecuted instantiation: _ZN5doris6Status10CorruptionILb1EJRmS2_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_EEES0_St17basic_string_viewIcS6_EDpOT0_ Unexecuted instantiation: _ZN5doris6Status10CorruptionILb1EJRjRmEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Unexecuted instantiation: _ZN5doris6Status13InternalErrorILb1EJPKcEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ _ZN5doris6Status9EndOfFileILb1EJEEES0_St17basic_string_viewIcSt11char_traitsIcEEDpOT0_ Line | Count | Source | 406 | 2.70k | static Status name(std::string_view msg, Args&&... args) { \ | 407 | 2.70k | return Error<ErrorCode::code, stacktrace>(msg, std::forward<Args>(args)...); \ | 408 | 2.70k | } |
|
409 | | |
410 | | ERROR_CTOR(PublishTimeout, PUBLISH_TIMEOUT) |
411 | | ERROR_CTOR(MemoryAllocFailed, MEM_ALLOC_FAILED) |
412 | | ERROR_CTOR(BufferAllocFailed, BUFFER_ALLOCATION_FAILED) |
413 | | ERROR_CTOR(InvalidArgument, INVALID_ARGUMENT) |
414 | | ERROR_CTOR(InvalidDataFormat, INVALID_DATA_FORMAT) |
415 | | ERROR_CTOR(InvalidJsonPath, INVALID_JSON_PATH) |
416 | | ERROR_CTOR(MinimumReservationUnavailable, MINIMUM_RESERVATION_UNAVAILABLE) |
417 | | ERROR_CTOR(Corruption, CORRUPTION) |
418 | | ERROR_CTOR(IOError, IO_ERROR) |
419 | | ERROR_CTOR(NotFound, NOT_FOUND) |
420 | | ERROR_CTOR(AlreadyExist, ALREADY_EXIST) |
421 | | ERROR_CTOR(NotSupported, NOT_IMPLEMENTED_ERROR) |
422 | | ERROR_CTOR(EndOfFile, END_OF_FILE) |
423 | | ERROR_CTOR(InternalError, INTERNAL_ERROR) |
424 | | ERROR_CTOR(WaitForRf, PIP_WAIT_FOR_RF) |
425 | | ERROR_CTOR(WaitForScannerContext, PIP_WAIT_FOR_SC) |
426 | | ERROR_CTOR(RuntimeError, RUNTIME_ERROR) |
427 | | ERROR_CTOR(Cancelled, CANCELLED) |
428 | | ERROR_CTOR(MemoryLimitExceeded, MEM_LIMIT_EXCEEDED) |
429 | | ERROR_CTOR(RpcError, THRIFT_RPC_ERROR) |
430 | | ERROR_CTOR(TimedOut, TIMEOUT) |
431 | | ERROR_CTOR(TooManyTasks, TOO_MANY_TASKS) |
432 | | ERROR_CTOR(Uninitialized, UNINITIALIZED) |
433 | | ERROR_CTOR(Aborted, ABORTED) |
434 | | ERROR_CTOR(DataQualityError, DATA_QUALITY_ERROR) |
435 | | ERROR_CTOR(NotAuthorized, NOT_AUTHORIZED) |
436 | | ERROR_CTOR(HttpError, HTTP_ERROR) |
437 | | #undef ERROR_CTOR |
438 | | |
439 | | template <int code> |
440 | 1.05M | bool is() const { |
441 | 1.05M | return code == _code; |
442 | 1.05M | } _ZNK5doris6Status2isILi30EEEbv Line | Count | Source | 440 | 1.04M | bool is() const { | 441 | 1.04M | return code == _code; | 442 | 1.04M | } |
_ZNK5doris6Status2isILin7002EEEbv Line | Count | Source | 440 | 6.02k | bool is() const { | 441 | 6.02k | return code == _code; | 442 | 6.02k | } |
_ZNK5doris6Status2isILi33EEEbv Line | Count | Source | 440 | 1 | bool is() const { | 441 | 1 | return code == _code; | 442 | 1 | } |
_ZNK5doris6Status2isILi39EEEbv Line | Count | Source | 440 | 1 | bool is() const { | 441 | 1 | return code == _code; | 442 | 1 | } |
_ZNK5doris6Status2isILin240EEEbv Line | Count | Source | 440 | 2.67k | bool is() const { | 441 | 2.67k | return code == _code; | 442 | 2.67k | } |
|
443 | | |
444 | 0 | void set_code(int code) { _code = code; } |
445 | | |
446 | 35.1M | bool ok() const { return _code == ErrorCode::OK; } |
447 | | |
448 | | bool is_io_error() const { |
449 | | return ErrorCode::IO_ERROR == _code || ErrorCode::READ_UNENOUGH == _code || |
450 | | ErrorCode::CHECKSUM_ERROR == _code || ErrorCode::FILE_DATA_ERROR == _code || |
451 | | ErrorCode::TEST_FILE_ERROR == _code; |
452 | | } |
453 | | |
454 | 0 | bool is_invalid_argument() const { return ErrorCode::INVALID_ARGUMENT == _code; } |
455 | 0 | bool is_invalid_data_format() const { return ErrorCode::INVALID_DATA_FORMAT == _code; } |
456 | | |
457 | | bool is_not_found() const { return _code == ErrorCode::NOT_FOUND; } |
458 | | bool is_not_authorized() const { return code() == TStatusCode::NOT_AUTHORIZED; } |
459 | | |
460 | | // Convert into TStatus. Call this if 'status_container' contains an optional |
461 | | // TStatus field named 'status'. This also sets __isset.status. |
462 | | template <typename T> |
463 | | void set_t_status(T* status_container) const { |
464 | | to_thrift(&status_container->status); |
465 | | status_container->__isset.status = true; |
466 | | } |
467 | | |
468 | | // Convert into TStatus. |
469 | | void to_thrift(TStatus* status) const; |
470 | | TStatus to_thrift() const; |
471 | | void to_protobuf(PStatus* status) const; |
472 | | |
473 | | std::string to_string() const; |
474 | | |
475 | | /// @return A json representation of this status. |
476 | | std::string to_json() const; |
477 | | |
478 | | int code() const { return _code; } |
479 | | |
480 | 262 | std::string msg() const { return _err_msg != nullptr ? _err_msg->_msg : ""; } |
481 | | |
482 | | /// Clone this status and add the specified prefix to the message. |
483 | | /// |
484 | | /// If this status is OK, then an OK status will be returned. |
485 | | /// |
486 | | /// @param [in] msg |
487 | | /// The message to prepend. |
488 | | /// @return A ref to Status object |
489 | | Status& prepend(std::string_view msg); |
490 | | |
491 | | /// Add the specified suffix to the message. |
492 | | /// |
493 | | /// If this status is OK, then an OK status will be returned. |
494 | | /// |
495 | | /// @param [in] msg |
496 | | /// The message to append. |
497 | | /// @return A ref to Status object |
498 | | Status& append(std::string_view msg); |
499 | | |
500 | | // if(!status) or if (status) will use this operator |
501 | 330k | operator bool() const { return this->ok(); } |
502 | | |
503 | | // Used like if (res == Status::OK()) |
504 | | // if the state is ok, then both code and precise code is not initialized properly, so that should check ok state |
505 | | // ignore error messages during comparison |
506 | 3.99k | bool operator==(const Status& st) const { return _code == st._code; } |
507 | | |
508 | | // Used like if (res != Status::OK()) |
509 | 8.35k | bool operator!=(const Status& st) const { return _code != st._code; } |
510 | | |
511 | | friend std::ostream& operator<<(std::ostream& ostr, const Status& status); |
512 | | |
513 | | private: |
514 | | int _code; |
515 | | struct ErrMsg { |
516 | | std::string _msg; |
517 | | #ifdef ENABLE_STACKTRACE |
518 | | std::string _stack; |
519 | | #endif |
520 | | }; |
521 | | std::unique_ptr<ErrMsg> _err_msg; |
522 | | |
523 | 247 | std::string code_as_string() const { |
524 | 247 | return (int)_code >= 0 ? doris::to_string(static_cast<TStatusCode::type>(_code)) |
525 | 247 | : fmt::format("E{}", (int16_t)_code); |
526 | 247 | } |
527 | | }; |
528 | | |
529 | 133 | inline std::ostream& operator<<(std::ostream& ostr, const Status& status) { |
530 | 133 | ostr << '[' << status.code_as_string() << ']'; |
531 | 133 | ostr << (status._err_msg ? status._err_msg->_msg : ""); |
532 | | #ifdef ENABLE_STACKTRACE |
533 | | if (status._err_msg && !status._err_msg->_stack.empty()) { |
534 | | ostr << '\n' << status._err_msg->_stack; |
535 | | } |
536 | | #endif |
537 | 133 | return ostr; |
538 | 133 | } |
539 | | |
540 | 61 | inline std::string Status::to_string() const { |
541 | 61 | std::stringstream ss; |
542 | 61 | ss << *this; |
543 | 61 | return ss.str(); |
544 | 61 | } |
545 | | |
546 | | // some generally useful macros |
547 | | #define RETURN_IF_ERROR(stmt) \ |
548 | 400 | do { \ |
549 | 400 | Status _status_ = (stmt); \ |
550 | 400 | if (UNLIKELY(!_status_.ok())) { \ |
551 | 0 | return _status_; \ |
552 | 0 | } \ |
553 | 400 | } while (false) |
554 | | |
555 | | #define PROPAGATE_FALSE(stmt) \ |
556 | | do { \ |
557 | | if (UNLIKELY(!static_cast<bool>(stmt))) { \ |
558 | | return false; \ |
559 | | } \ |
560 | | } while (false) |
561 | | |
562 | | #define THROW_IF_ERROR(stmt) \ |
563 | | do { \ |
564 | | Status _status_ = (stmt); \ |
565 | | if (UNLIKELY(!_status_.ok())) { \ |
566 | | throw Exception(_status_); \ |
567 | | } \ |
568 | | } while (false) |
569 | | |
570 | | #define RETURN_ERROR_IF_NON_VEC \ |
571 | | return Status::NotSupported("Non-vectorized engine is not supported since Doris 2.0."); |
572 | | |
573 | | #define RETURN_IF_STATUS_ERROR(status, stmt) \ |
574 | | do { \ |
575 | | status = (stmt); \ |
576 | | if (UNLIKELY(!status.ok())) { \ |
577 | | return; \ |
578 | | } \ |
579 | | } while (false) |
580 | | |
581 | | #define EXIT_IF_ERROR(stmt) \ |
582 | | do { \ |
583 | | Status _status_ = (stmt); \ |
584 | | if (UNLIKELY(!_status_.ok())) { \ |
585 | | LOG(ERROR) << _status_; \ |
586 | | exit(1); \ |
587 | | } \ |
588 | | } while (false) |
589 | | |
590 | | /// @brief Emit a warning if @c to_call returns a bad status. |
591 | | #define WARN_IF_ERROR(to_call, warning_prefix) \ |
592 | | do { \ |
593 | | Status _s = (to_call); \ |
594 | | if (UNLIKELY(!_s.ok())) { \ |
595 | | LOG(WARNING) << (warning_prefix) << ": " << _s; \ |
596 | | } \ |
597 | | } while (false); |
598 | | |
599 | | #define RETURN_WITH_WARN_IF_ERROR(stmt, ret_code, warning_prefix) \ |
600 | | do { \ |
601 | | Status _s = (stmt); \ |
602 | | if (UNLIKELY(!_s.ok())) { \ |
603 | | LOG(WARNING) << (warning_prefix) << ", error: " << _s; \ |
604 | | return ret_code; \ |
605 | | } \ |
606 | | } while (false); |
607 | | |
608 | | #define RETURN_NOT_OK_STATUS_WITH_WARN(stmt, warning_prefix) \ |
609 | | do { \ |
610 | | Status _s = (stmt); \ |
611 | | if (UNLIKELY(!_s.ok())) { \ |
612 | | LOG(WARNING) << (warning_prefix) << ", error: " << _s; \ |
613 | | return _s; \ |
614 | | } \ |
615 | | } while (false); |
616 | | |
617 | | template <typename T> |
618 | | using Result = expected<T, Status>; |
619 | | |
620 | | using ResultError = unexpected<Status>; |
621 | | |
622 | | #define RETURN_IF_ERROR_RESULT(stmt) \ |
623 | | do { \ |
624 | | Status _status_ = (stmt); \ |
625 | | if (UNLIKELY(!_status_.ok())) { \ |
626 | | return unexpected(std::move(_status_)); \ |
627 | | } \ |
628 | | } while (false) |
629 | | |
630 | | } // namespace doris |