diff --git a/cpp/src/arrow/status.cc b/cpp/src/arrow/status.cc index 5a81a60cdc42e..785db45975227 100644 --- a/cpp/src/arrow/status.cc +++ b/cpp/src/arrow/status.cc @@ -26,7 +26,6 @@ Status::Status(StatusCode code, const std::string& msg) Status::Status(StatusCode code, std::string msg, std::shared_ptr detail) { ARROW_CHECK_NE(code, StatusCode::OK) << "Cannot construct ok status with message"; - assert(code != StatusCode::OK); state_ = new State; state_->code = code; state_->msg = std::move(msg); diff --git a/cpp/src/plasma/client.cc b/cpp/src/plasma/client.cc index ac525944f7a1c..26518596ab3e6 100644 --- a/cpp/src/plasma/client.cc +++ b/cpp/src/plasma/client.cc @@ -791,12 +791,12 @@ Status PlasmaClient::Impl::Seal(const ObjectID& object_id) { auto object_entry = objects_in_use_.find(object_id); if (object_entry == objects_in_use_.end()) { - return MakePlasmaError("Seal() called on an object without a reference to it", - PlasmaErrorCode::PlasmaObjectNonexistent); + return MakePlasmaError(PlasmaErrorCode::PlasmaObjectNonexistent,"Seal() called on an object without a reference to it" + ); } if (object_entry->second->is_sealed) { - return MakePlasmaError("Seal() called on an already sealed object", - PlasmaErrorCode::PlasmaObjectAlreadySealed); + return MakePlasmaError(PlasmaErrorCode::PlasmaObjectAlreadySealed,"Seal() called on an already sealed object" + ); } object_entry->second->is_sealed = true; @@ -897,7 +897,7 @@ Status PlasmaClient::Impl::Hash(const ObjectID& object_id, uint8_t* digest) { RETURN_NOT_OK(Get({object_id}, 0, &object_buffers)); // If the object was not retrieved, return false. if (!object_buffers[0].data) { - return MakePlasmaError("Object not found", PlasmaErrorCode::PlasmaObjectNonexistent); + return MakePlasmaError(PlasmaErrorCode::PlasmaObjectNonexistent, "Object not found"); } // Compute the hash. uint64_t hash = ComputeObjectHash(object_buffers[0]); diff --git a/cpp/src/plasma/common.cc b/cpp/src/plasma/common.cc index 00391af2192fb..bbcd2c9c3f13c 100644 --- a/cpp/src/plasma/common.cc +++ b/cpp/src/plasma/common.cc @@ -30,7 +30,7 @@ namespace plasma { namespace { -const char kErrorDetailTypeId[] = "plasma status detail"; +const char kErrorDetailTypeId[] = "plasma::PlasmaStatusDetail"; class PlasmaStatusDetail : public arrow::StatusDetail { public: @@ -76,7 +76,7 @@ bool IsPlasmaStatus(const arrow::Status& status, PlasmaErrorCode code) { using arrow::Status; -arrow::Status MakePlasmaError(std::string message, PlasmaErrorCode code) { +arrow::Status MakePlasmaError(PlasmaErrorCode code, std::string message) { arrow::StatusCode arrow_code = arrow::StatusCode::UnknownError; switch (code) { case PlasmaErrorCode::PlasmaObjectExists: diff --git a/cpp/src/plasma/common.h b/cpp/src/plasma/common.h index d5803081687b5..d42840cfbd2e5 100644 --- a/cpp/src/plasma/common.h +++ b/cpp/src/plasma/common.h @@ -48,7 +48,7 @@ enum class PlasmaErrorCode : int8_t { PlasmaObjectAlreadySealed = 4, }; -ARROW_EXPORT arrow::Status MakePlasmaError(std::string message, PlasmaErrorCode code); +ARROW_EXPORT arrow::Status MakePlasmaError(PlasmaErrorCode code, std::string message); /// Return true iff the status indicates an already existing Plasma object. ARROW_EXPORT bool IsPlasmaObjectExists(const arrow::Status& status); /// Return true iff the status indicates a non-existent Plasma object. diff --git a/cpp/src/plasma/protocol.cc b/cpp/src/plasma/protocol.cc index 20f246c6c97dc..cf6d088e2e557 100644 --- a/cpp/src/plasma/protocol.cc +++ b/cpp/src/plasma/protocol.cc @@ -86,14 +86,14 @@ Status PlasmaErrorStatus(fb::PlasmaError plasma_error) { case fb::PlasmaError::OK: return Status::OK(); case fb::PlasmaError::ObjectExists: - return MakePlasmaError("object already exists in the plasma store", - PlasmaErrorCode::PlasmaObjectExists); + return MakePlasmaError(PlasmaErrorCode::PlasmaObjectExists, "object already exists in the plasma store" + ); case fb::PlasmaError::ObjectNonexistent: - return MakePlasmaError("object does not exist in the plasma store", - PlasmaErrorCode::PlasmaObjectNonexistent); + return MakePlasmaError(PlasmaErrorCode::PlasmaObjectNonexistent, "object does not exist in the plasma store", + ); case fb::PlasmaError::OutOfMemory: - return MakePlasmaError("object does not fit in the plasma store", - PlasmaErrorCode::PlasmaStoreFull); + return MakePlasmaError(PlasmaErrorCode::PlasmaStoreFull, "object does not fit in the plasma store", + ); default: ARROW_LOG(FATAL) << "unknown plasma error code " << static_cast(plasma_error); }