cpp/src/arrow/flight/internal.cc
/// Convert a gRPC status to an Arrow status, ignoring any
/// implementation-defined headers that encode further detail.
Convert a gRPC status to an Arrow status, ignoring any
implementation-defined headers that encode further detail.
Convert a gRPC status to an Arrow status ignoring any implementation - defined headers that encode further detail .
static Status FromGrpcCode(const grpc::Status& grpc_status) {
  switch (grpc_status.error_code()) {
    case grpc::StatusCode::OK:
      return Status::OK();
    case grpc::StatusCode::CANCELLED:
      return Status::IOError("gRPC cancelled call, with message: ",
                             grpc_status.error_message())
          .WithDetail(std::make_shared<FlightStatusDetail>(FlightStatusCode::Cancelled));
    case grpc::StatusCode::UNKNOWN: {
      std::stringstream ss;
      ss << "Flight RPC failed with message: " << grpc_status.error_message();
      return Status::UnknownError(ss.str()).WithDetail(
          std::make_shared<FlightStatusDetail>(FlightStatusCode::Failed));
    }
    case grpc::StatusCode::INVALID_ARGUMENT:
      return Status::Invalid("gRPC returned invalid argument error, with message: ",
                             grpc_status.error_message());
    case grpc::StatusCode::DEADLINE_EXCEEDED:
      return Status::IOError("gRPC returned deadline exceeded error, with message: ",
                             grpc_status.error_message())
          .WithDetail(std::make_shared<FlightStatusDetail>(FlightStatusCode::TimedOut));
    case grpc::StatusCode::NOT_FOUND:
      return Status::KeyError("gRPC returned not found error, with message: ",
                              grpc_status.error_message());
    case grpc::StatusCode::ALREADY_EXISTS:
      return Status::AlreadyExists("gRPC returned already exists error, with message: ",
                                   grpc_status.error_message());
    case grpc::StatusCode::PERMISSION_DENIED:
      return Status::IOError("gRPC returned permission denied error, with message: ",
                             grpc_status.error_message())
          .WithDetail(
              std::make_shared<FlightStatusDetail>(FlightStatusCode::Unauthorized));
    case grpc::StatusCode::RESOURCE_EXHAUSTED:
      return Status::Invalid("gRPC returned resource exhausted error, with message: ",
                             grpc_status.error_message());
    case grpc::StatusCode::FAILED_PRECONDITION:
      return Status::Invalid("gRPC returned precondition failed error, with message: ",
                             grpc_status.error_message());
    case grpc::StatusCode::ABORTED:
      return Status::IOError("gRPC returned aborted error, with message: ",
                             grpc_status.error_message())
          .WithDetail(std::make_shared<FlightStatusDetail>(FlightStatusCode::Internal));
    case grpc::StatusCode::OUT_OF_RANGE:
      return Status::Invalid("gRPC returned out-of-range error, with message: ",
                             grpc_status.error_message());
    case grpc::StatusCode::UNIMPLEMENTED:
      return Status::NotImplemented("gRPC returned unimplemented error, with message: ",
                                    grpc_status.error_message());
    case grpc::StatusCode::INTERNAL:
      return Status::IOError("gRPC returned internal error, with message: ",
                             grpc_status.error_message())
          .WithDetail(std::make_shared<FlightStatusDetail>(FlightStatusCode::Internal));
    case grpc::StatusCode::UNAVAILABLE:
      return Status::IOError("gRPC returned unavailable error, with message: ",
                             grpc_status.error_message())
          .WithDetail(
              std::make_shared<FlightStatusDetail>(FlightStatusCode::Unavailable));
    case grpc::StatusCode::DATA_LOSS:
      return Status::IOError("gRPC returned data loss error, with message: ",
                             grpc_status.error_message())
          .WithDetail(std::make_shared<FlightStatusDetail>(FlightStatusCode::Internal));
    case grpc::StatusCode::UNAUTHENTICATED:
      return Status::IOError("gRPC returned unauthenticated error, with message: ",
                             grpc_status.error_message())
          .WithDetail(
              std::make_shared<FlightStatusDetail>(FlightStatusCode::Unauthenticated));
    default:
      return Status::UnknownError("gRPC failed with error code ",
                                  grpc_status.error_code(),
                                  " and message: ", grpc_status.error_message());
  }
}
static Status FromGrpcCode ( const grpc :: Status & grpc_status ) { switch ( grpc_status . error_code ( ) ) { case grpc :: StatusCode :: OK : return Status :: OK ( ) ; case grpc :: StatusCode :: CANCELLED : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Cancelled ) ) ; case grpc :: StatusCode :: UNKNOWN : { std :: stringstream ss ; ss << " " << grpc_status . error_message ( ) ; return Status :: UnknownError ( ss . str ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Failed ) ) ; } case grpc :: StatusCode :: INVALID_ARGUMENT : return Status :: Invalid ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: DEADLINE_EXCEEDED : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: TimedOut ) ) ; case grpc :: StatusCode :: NOT_FOUND : return Status :: KeyError ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: ALREADY_EXISTS : return Status :: AlreadyExists ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: PERMISSION_DENIED : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Unauthorized ) ) ; case grpc :: StatusCode :: RESOURCE_EXHAUSTED : return Status :: Invalid ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: FAILED_PRECONDITION : return Status :: Invalid ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: ABORTED : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Internal ) ) ; case grpc :: StatusCode :: OUT_OF_RANGE : return Status :: Invalid ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: UNIMPLEMENTED : return Status :: NotImplemented ( " " , grpc_status . error_message ( ) ) ; case grpc :: StatusCode :: INTERNAL : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Internal ) ) ; case grpc :: StatusCode :: UNAVAILABLE : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Unavailable ) ) ; case grpc :: StatusCode :: DATA_LOSS : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Internal ) ) ; case grpc :: StatusCode :: UNAUTHENTICATED : return Status :: IOError ( " " , grpc_status . error_message ( ) ) . WithDetail ( std :: make_shared < FlightStatusDetail > ( FlightStatusCode :: Unauthenticated ) ) ; default : return Status :: UnknownError ( " " , grpc_status . error_code ( ) , " " , grpc_status . error_message ( ) ) ; } }
Convert a gRPC status to an Arrow status, ignoring any
implementation-defined headers that encode further detail.
Convert a gRPC status to an Arrow status ignoring any implementation - defined headers that encode further detail .