arrow::Status FromUcsStatus()

in dissociated-ipc/ucx_utils.cc [116:286]


arrow::Status FromUcsStatus(const std::string& context, ucs_status_t ucs_status) {
  switch (ucs_status) {
    case UCS_OK:
      return arrow::Status::OK();
    case UCS_INPROGRESS:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_INPROGRESS ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NO_MESSAGE:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_NO_MESSAGE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NO_RESOURCE:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_NO_RESOURCE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_IO_ERROR:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_IO_ERROR ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NO_MEMORY:
      return arrow::Status::OutOfMemory(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_NO_MEMORY ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_INVALID_PARAM:
      return arrow::Status::Invalid(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_INVALID_PARAM ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_UNREACHABLE:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_UNREACHABLE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_INVALID_ADDR:
      return arrow::Status::Invalid(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_INVALID_ADDR ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NOT_IMPLEMENTED:
      return arrow::Status::NotImplemented(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_NOT_IMPLEMENTED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_MESSAGE_TRUNCATED:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_MESSAGE_TRUNCATED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NO_PROGRESS:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_NO_PROGRESS ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_BUFFER_TOO_SMALL:
      return arrow::Status::Invalid(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_BUFFER_TOO_SMALL ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NO_ELEM:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_NO_ELEM ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_SOME_CONNECTS_FAILED:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_SOME_CONNECTS_FAILED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NO_DEVICE:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_NO_DEVICE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_BUSY:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_BUSY ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_CANCELED:
      return arrow::Status::Cancelled(context, ": UCX error ",
                                      static_cast<int32_t>(ucs_status), ": ",
                                      "UCS_ERR_CANCELED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_SHMEM_SEGMENT:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_SHMEM_SEGMENT ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_ALREADY_EXISTS:
      return arrow::Status::AlreadyExists(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_ALREADY_EXISTS ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_OUT_OF_RANGE:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_OUT_OF_RANGE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_TIMED_OUT:
      return arrow::Status::Cancelled(context, ": UCX error ",
                                      static_cast<int32_t>(ucs_status), ": ",
                                      "UCS_ERR_TIMED_OUT ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_EXCEEDS_LIMIT:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_EXCEEDS_LIMIT ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_UNSUPPORTED:
      return arrow::Status::NotImplemented(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_UNSUPPORTED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_REJECTED:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_REJECTED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_NOT_CONNECTED:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_NOT_CONNECTED ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_CONNECTION_RESET:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_CONNECTION_RESET ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_FIRST_LINK_FAILURE:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_FIRST_LINK_FAILURE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_LAST_LINK_FAILURE:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_LAST_LINK_FAILURE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_FIRST_ENDPOINT_FAILURE:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_FIRST_ENDPOINT_FAILURE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_LAST_ENDPOINT_FAILURE:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_LAST_ENDPOINT_FAILURE ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_ENDPOINT_TIMEOUT:
      return arrow::Status::IOError(
                 context, ": UCX error ", static_cast<int32_t>(ucs_status), ": ",
                 "UCS_ERR_ENDPOINT_TIMEOUT ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    case UCS_ERR_LAST:
      return arrow::Status::IOError(context, ": UCX error ",
                                    static_cast<int32_t>(ucs_status), ": ",
                                    "UCS_ERR_LAST ", ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
    default:
      return arrow::Status::UnknownError(
                 context, ": Unknown UCX error: ", static_cast<int32_t>(ucs_status), " ",
                 ucs_status_string(ucs_status))
          .WithDetail(std::make_shared<UcxStatusDetail>(ucs_status));
  }
}