cpp/src/arrow/flight/internal.cc
/// Try to extract a status from gRPC trailers.
/// Return Status::OK if found, an error otherwise.
Try to extract a status from gRPC trailers.
Return Status::OK if found, an error otherwise.
Try to extract a status from gRPC trailers . Return Status :: OK if found an error otherwise .
static Status FromGrpcContext(const grpc::ClientContext& ctx, Status* status,
                              std::shared_ptr<FlightStatusDetail> flightStatusDetail) {
  const std::multimap<grpc::string_ref, grpc::string_ref>& trailers =
      ctx.GetServerTrailingMetadata();
  const auto code_val = trailers.find(kGrpcStatusCodeHeader);
  if (code_val == trailers.end()) {
    return Status::IOError("Status code header not found");
  }
  const grpc::string_ref code_ref = code_val->second;
  StatusCode code = {};
  RETURN_NOT_OK(StatusCodeFromString(code_ref, &code));
  const auto message_val = trailers.find(kGrpcStatusMessageHeader);
  if (message_val == trailers.end()) {
    return Status::IOError("Status message header not found");
  }
  const grpc::string_ref message_ref = message_val->second;
  std::string message = std::string(message_ref.data(), message_ref.size());
  const auto detail_val = trailers.find(kGrpcStatusDetailHeader);
  if (detail_val != trailers.end()) {
    const grpc::string_ref detail_ref = detail_val->second;
    message += ". Detail: ";
    message += std::string(detail_ref.data(), detail_ref.size());
  }
  const auto grpc_detail_val = trailers.find(kBinaryErrorDetailsKey);
  if (grpc_detail_val != trailers.end()) {
    const grpc::string_ref detail_ref = grpc_detail_val->second;
    std::string bin_detail = std::string(detail_ref.data(), detail_ref.size());
    if (!flightStatusDetail) {
      flightStatusDetail =
          std::make_shared<FlightStatusDetail>(FlightStatusCode::Internal);
    }
    flightStatusDetail->set_extra_info(bin_detail);
  }
  *status = Status(code, message, flightStatusDetail);
  return Status::OK();
}
static Status FromGrpcContext ( const grpc :: ClientContext & ctx , Status * status , std :: shared_ptr < FlightStatusDetail > flightStatusDetail ) { const std :: multimap < grpc :: string_ref , grpc :: string_ref > & trailers = ctx . GetServerTrailingMetadata ( ) ; const auto code_val = trailers . find ( kGrpcStatusCodeHeader ) ; if ( code_val == trailers . end ( ) ) { return Status :: IOError ( " " ) ; } const grpc :: string_ref code_ref = code_val -> second ; StatusCode code = { } ; RETURN_NOT_OK ( StatusCodeFromString ( code_ref , & code ) ) ; const auto message_val = trailers . find ( kGrpcStatusMessageHeader ) ; if ( message_val == trailers . end ( ) ) { return Status :: IOError ( " " ) ; } const grpc :: string_ref message_ref = message_val -> second ; std :: string message = std :: string ( message_ref . data ( ) , message_ref . size ( ) ) ; const auto detail_val = trailers . find ( kGrpcStatusDetailHeader ) ; if ( detail_val != trailers . end ( ) ) { const grpc :: string_ref detail_ref = detail_val -> second ; message += " " ; message += std :: string ( detail_ref . data ( ) , detail_ref . size ( ) ) ; } const auto grpc_detail_val = trailers . find ( kBinaryErrorDetailsKey ) ; if ( grpc_detail_val != trailers . end ( ) ) { const grpc :: string_ref detail_ref = grpc_detail_val -> second ; std :: string bin_detail = std :: string ( detail_ref . data ( ) , detail_ref . size ( ) ) ; if ( ! flightStatusDetail ) { flightStatusDetail = std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Internal ) ; } flightStatusDetail -> set_extra_info ( bin_detail ) ; } * status = Status ( code , message , flightStatusDetail ) ; return Status :: OK ( ) ; }
Try to extract a status from gRPC trailers.
Try to extract a status from gRPC trailers .