cpp/src/arrow/flight/internal.cc
/// Convert an Arrow status to a gRPC status, and add extra headers to
/// the response to encode the original Arrow status.
Convert an Arrow status to a gRPC status, and add extra headers to
the response to encode the original Arrow status.
Convert an Arrow status to a gRPC status and add extra headers to the response to encode the original Arrow status .
grpc::Status ToGrpcStatus(const Status& arrow_status, grpc::ServerContext* ctx) {
  grpc::Status status = ToRawGrpcStatus(arrow_status);
  if (!status.ok() && ctx) {
    const std::string code = std::to_string(static_cast<int>(arrow_status.code()));
    ctx->AddTrailingMetadata(internal::kGrpcStatusCodeHeader, code);
    ctx->AddTrailingMetadata(internal::kGrpcStatusMessageHeader, arrow_status.message());
    if (arrow_status.detail()) {
      const std::string detail_string = arrow_status.detail()->ToString();
      ctx->AddTrailingMetadata(internal::kGrpcStatusDetailHeader, detail_string);
    }
    auto fsd = FlightStatusDetail::UnwrapStatus(arrow_status);
    if (fsd && !fsd->extra_info().empty()) {
      ctx->AddTrailingMetadata(internal::kBinaryErrorDetailsKey, fsd->extra_info());
    }
  }
  return status;
}
grpc :: Status ToGrpcStatus ( const Status & arrow_status , grpc :: ServerContext * ctx ) { grpc :: Status status = ToRawGrpcStatus ( arrow_status ) ; if ( ! status . ok ( ) && ctx ) { const std :: string code = std :: to_string ( static_cast < int > ( arrow_status . code ( ) ) ) ; ctx -> AddTrailingMetadata ( internal :: kGrpcStatusCodeHeader , code ) ; ctx -> AddTrailingMetadata ( internal :: kGrpcStatusMessageHeader , arrow_status . message ( ) ) ; if ( arrow_status . detail ( ) ) { const std :: string detail_string = arrow_status . detail ( ) -> ToString ( ) ; ctx -> AddTrailingMetadata ( internal :: kGrpcStatusDetailHeader , detail_string ) ; } auto fsd = FlightStatusDetail :: UnwrapStatus ( arrow_status ) ; if ( fsd && ! fsd -> extra_info ( ) . empty ( ) ) { ctx -> AddTrailingMetadata ( internal :: kBinaryErrorDetailsKey , fsd -> extra_info ( ) ) ; } } return status ; }
Convert an Arrow status to a gRPC status, and add extra headers to
the response to encode the original Arrow status.
Convert an Arrow status to a gRPC status and add extra headers to the response to encode the original Arrow status .