diff --git a/tensorflow_io/core/kernels/bigquery/bigquery_lib.cc b/tensorflow_io/core/kernels/bigquery/bigquery_lib.cc index 534c1b223..b571693e8 100644 --- a/tensorflow_io/core/kernels/bigquery/bigquery_lib.cc +++ b/tensorflow_io/core/kernels/bigquery/bigquery_lib.cc @@ -17,43 +17,43 @@ limitations under the License. namespace tensorflow { namespace { -::tensorflow::error::Code GcpErrorCodeToTfErrorCode(::grpc::StatusCode code) { +absl::StatusCode GcpErrorCodeToTfErrorCode(::grpc::StatusCode code) { switch (code) { case ::grpc::StatusCode::OK: - return ::tensorflow::error::OK; + return absl::StatusCode::kOk; case ::grpc::StatusCode::CANCELLED: - return ::tensorflow::error::CANCELLED; + return absl::StatusCode::kCancelled; case ::grpc::StatusCode::INVALID_ARGUMENT: - return ::tensorflow::error::INVALID_ARGUMENT; + return absl::StatusCode::kInvalidArgument; case ::grpc::StatusCode::DEADLINE_EXCEEDED: - return ::tensorflow::error::DEADLINE_EXCEEDED; + return absl::StatusCode::kDeadlineExceeded; case ::grpc::StatusCode::NOT_FOUND: - return ::tensorflow::error::NOT_FOUND; + return absl::StatusCode::kNotFound; case ::grpc::StatusCode::ALREADY_EXISTS: - return ::tensorflow::error::ALREADY_EXISTS; + return absl::StatusCode::kAlreadyExists; case ::grpc::StatusCode::PERMISSION_DENIED: - return ::tensorflow::error::PERMISSION_DENIED; + return absl::StatusCode::kPermissionDenied; case ::grpc::StatusCode::UNAUTHENTICATED: - return ::tensorflow::error::UNAUTHENTICATED; + return absl::StatusCode::kUnauthenticated; case ::grpc::StatusCode::RESOURCE_EXHAUSTED: - return ::tensorflow::error::RESOURCE_EXHAUSTED; + return absl::StatusCode::kResourceExhausted; case ::grpc::StatusCode::FAILED_PRECONDITION: - return ::tensorflow::error::FAILED_PRECONDITION; + return absl::StatusCode::kFailedPrecondition; case ::grpc::StatusCode::ABORTED: - return ::tensorflow::error::ABORTED; + return absl::StatusCode::kAborted; case ::grpc::StatusCode::OUT_OF_RANGE: - return ::tensorflow::error::OUT_OF_RANGE; + return absl::StatusCode::kOutOfRange; case ::grpc::StatusCode::UNIMPLEMENTED: - return ::tensorflow::error::UNIMPLEMENTED; + return absl::StatusCode::kUnimplemented; case ::grpc::StatusCode::INTERNAL: - return ::tensorflow::error::INTERNAL; + return absl::StatusCode::kInternal; case ::grpc::StatusCode::UNAVAILABLE: - return ::tensorflow::error::UNAVAILABLE; + return absl::StatusCode::kUnavailable; case ::grpc::StatusCode::DATA_LOSS: - return ::tensorflow::error::DATA_LOSS; + return absl::StatusCode::kDataLoss; case ::grpc::StatusCode::UNKNOWN: // Fallthrough default: - return ::tensorflow::error::UNKNOWN; + return absl::StatusCode::kUnknown; } } } // namespace @@ -62,7 +62,8 @@ Status GrpcStatusToTfStatus(const ::grpc::Status& status) { if (status.ok()) { return OkStatus(); } - return Status(GcpErrorCodeToTfErrorCode(status.error_code()), + return Status(static_cast( + GcpErrorCodeToTfErrorCode(status.error_code())), strings::StrCat("Error reading from Cloud BigQuery: ", status.error_message())); } @@ -73,7 +74,8 @@ string GrpcStatusToString(const ::grpc::Status& status) { } return strings::StrCat("Status code: ", ::tensorflow::error::Code_Name( - GcpErrorCodeToTfErrorCode(status.error_code())), + static_cast( + GcpErrorCodeToTfErrorCode(status.error_code()))), " error message:", status.error_message(), " error details: ", status.error_details()); } diff --git a/tensorflow_io/core/kernels/bigtable/bigtable_dataset_kernel.cc b/tensorflow_io/core/kernels/bigtable/bigtable_dataset_kernel.cc index b1585895f..26913a77d 100644 --- a/tensorflow_io/core/kernels/bigtable/bigtable_dataset_kernel.cc +++ b/tensorflow_io/core/kernels/bigtable/bigtable_dataset_kernel.cc @@ -32,43 +32,43 @@ namespace tensorflow { namespace data { namespace { -tensorflow::error::Code GoogleCloudErrorCodeToTfErrorCode( +absl::StatusCode GoogleCloudErrorCodeToTfErrorCode( ::google::cloud::StatusCode code) { switch (code) { case ::google::cloud::StatusCode::kOk: - return ::tensorflow::error::OK; + return absl::StatusCode::kOk; case ::google::cloud::StatusCode::kCancelled: - return ::tensorflow::error::CANCELLED; + return absl::StatusCode::kCancelled; case ::google::cloud::StatusCode::kInvalidArgument: - return ::tensorflow::error::INVALID_ARGUMENT; + return absl::StatusCode::kInvalidArgument; case ::google::cloud::StatusCode::kDeadlineExceeded: - return ::tensorflow::error::DEADLINE_EXCEEDED; + return absl::StatusCode::kDeadlineExceeded; case ::google::cloud::StatusCode::kNotFound: - return ::tensorflow::error::NOT_FOUND; + return absl::StatusCode::kNotFound; case ::google::cloud::StatusCode::kAlreadyExists: - return ::tensorflow::error::ALREADY_EXISTS; + return absl::StatusCode::kAlreadyExists; case ::google::cloud::StatusCode::kPermissionDenied: - return ::tensorflow::error::PERMISSION_DENIED; + return absl::StatusCode::kPermissionDenied; case ::google::cloud::StatusCode::kUnauthenticated: - return ::tensorflow::error::UNAUTHENTICATED; + return absl::StatusCode::kUnauthenticated; case ::google::cloud::StatusCode::kResourceExhausted: - return ::tensorflow::error::RESOURCE_EXHAUSTED; + return absl::StatusCode::kResourceExhausted; case ::google::cloud::StatusCode::kFailedPrecondition: - return ::tensorflow::error::FAILED_PRECONDITION; + return absl::StatusCode::kFailedPrecondition; case ::google::cloud::StatusCode::kAborted: - return ::tensorflow::error::ABORTED; + return absl::StatusCode::kAborted; case ::google::cloud::StatusCode::kOutOfRange: - return ::tensorflow::error::OUT_OF_RANGE; + return absl::StatusCode::kOutOfRange; case ::google::cloud::StatusCode::kUnimplemented: - return ::tensorflow::error::UNIMPLEMENTED; + return absl::StatusCode::kUnimplemented; case ::google::cloud::StatusCode::kInternal: - return ::tensorflow::error::INTERNAL; + return absl::StatusCode::kInternal; case ::google::cloud::StatusCode::kUnavailable: - return ::tensorflow::error::UNAVAILABLE; + return absl::StatusCode::kUnavailable; case ::google::cloud::StatusCode::kDataLoss: - return ::tensorflow::error::DATA_LOSS; + return absl::StatusCode::kDataLoss; default: - return ::tensorflow::error::UNKNOWN; + return absl::StatusCode::kUnnown; } } @@ -77,7 +77,8 @@ Status GoogleCloudStatusToTfStatus(const ::google::cloud::Status& status) { return OkStatus(); } return Status( - GoogleCloudErrorCodeToTfErrorCode(status.code()), + static_cast<::tensorflow::errors::Code>( + GoogleCloudErrorCodeToTfErrorCode(status.code())), strings::StrCat("Error reading from Cloud Bigtable: ", status.message())); } diff --git a/tensorflow_io/core/kernels/gsmemcachedfs/gce_memcached_server_list_provider.cc b/tensorflow_io/core/kernels/gsmemcachedfs/gce_memcached_server_list_provider.cc index 54fe68317..cf1bac6ea 100644 --- a/tensorflow_io/core/kernels/gsmemcachedfs/gce_memcached_server_list_provider.cc +++ b/tensorflow_io/core/kernels/gsmemcachedfs/gce_memcached_server_list_provider.cc @@ -45,8 +45,9 @@ Status GceMemcachedServerListProvider::GetServerList( if (success) { return OkStatus(); } else { - return Status(tensorflow::error::FAILED_PRECONDITION, - "Unexpected server list format"); + return Status( + static_cast(absl::StatusCode::kFailedPrecondition), + "Unexpected server list format"); } }