MCPcopy Create free account
hub / github.com/apache/arrow / ReconstructStatus

Function ReconstructStatus

cpp/src/arrow/flight/transport.cc:322–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322Status ReconstructStatus(const std::string& code_str, const Status& current_status,
323 std::optional<std::string> message,
324 std::optional<std::string> detail_message,
325 std::optional<std::string> detail_bin,
326 std::shared_ptr<FlightStatusDetail> detail) {
327 // Bounce through std::string to get a proper null-terminated C string
328 StatusCode status_code = current_status.code();
329 std::stringstream status_message;
330 try {
331 const auto code_int = std::stoi(code_str);
332 switch (code_int) {
333 case static_cast<int>(StatusCode::OutOfMemory):
334 case static_cast<int>(StatusCode::KeyError):
335 case static_cast<int>(StatusCode::TypeError):
336 case static_cast<int>(StatusCode::Invalid):
337 case static_cast<int>(StatusCode::IOError):
338 case static_cast<int>(StatusCode::CapacityError):
339 case static_cast<int>(StatusCode::IndexError):
340 case static_cast<int>(StatusCode::Cancelled):
341 case static_cast<int>(StatusCode::UnknownError):
342 case static_cast<int>(StatusCode::NotImplemented):
343 case static_cast<int>(StatusCode::SerializationError):
344 case static_cast<int>(StatusCode::RError):
345 case static_cast<int>(StatusCode::CodeGenError):
346 case static_cast<int>(StatusCode::ExpressionValidationError):
347 case static_cast<int>(StatusCode::ExecutionError):
348 case static_cast<int>(StatusCode::AlreadyExists): {
349 status_code = static_cast<StatusCode>(code_int);
350 break;
351 }
352 default: {
353 status_message << ". Also, server sent unknown or invalid Arrow status code "
354 << code_str;
355 break;
356 }
357 }
358 } catch (...) {
359 status_message << ". Also, server sent unknown or invalid Arrow status code "
360 << code_str;
361 }
362
363 status_message << (message.has_value() ? *message : current_status.message());
364 if (detail_message.has_value()) {
365 status_message << ". Detail: " << *detail_message;
366 }
367 if (detail_bin.has_value()) {
368 if (!detail) {
369 detail = std::make_shared<FlightStatusDetail>(FlightStatusCode::Internal);
370 }
371 detail->set_extra_info(std::move(*detail_bin));
372 }
373 return Status(status_code, status_message.str(), std::move(detail));
374}
375
376} // namespace internal
377} // namespace flight

Callers 2

TESTFunction · 0.85
FromGrpcContextFunction · 0.85

Calls 4

set_extra_infoMethod · 0.80
strMethod · 0.80
StatusClass · 0.70
codeMethod · 0.45

Tested by 1

TESTFunction · 0.68