Skip to content

Conversation

@kolea2
Copy link
Contributor

@kolea2 kolea2 commented Apr 25, 2024

Building on top of changes in #1400, this PR reverts the updates in #1244 and instead translates gRPC error codes into existing Datastore ones.

This follows the same logic and patterns as in java-storage: https://github.com/googleapis/java-storage/blob/main/google-cloud-storage/src/main/java/com/google/cloud/storage/GrpcToHttpStatusCodeTranslation.java

…t gRPC status codes to existing Datastore codes
@kolea2 kolea2 requested review from a team as code owners April 25, 2024 14:38
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Apr 25, 2024
@kolea2 kolea2 requested a review from BenWhitehead April 25, 2024 14:38
@product-auto-label product-auto-label bot added the api: datastore Issues related to the googleapis/java-datastore API. label Apr 25, 2024
@kolea2 kolea2 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 25, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 25, 2024
@kolea2 kolea2 requested a review from a team as a code owner April 25, 2024 15:46
Copy link
Collaborator

@BenWhitehead BenWhitehead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor things, that may not need to be addressed in this PR (or at all)

GrpcToDatastoreCodeTranslation.grpcCodeToDatastoreStatusCode(gsc.getTransportCode());
}

// If there is a gRPC exception in our cause change pull it's error message up to be our
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If there is a gRPC exception in our cause change pull it's error message up to be our
// If there is a gRPC exception in our cause, pull it's error message up to be our

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in subsequent commit.

}

private void assertDatastoreException(
DatastoreException expected, String reason, int datastoreStatusCode) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this naming feels backward to me. I interpret expected as the value that is expected to hold in the assertion, not the exception that was expected to be thrown.

May not be worth the hassell, but I prefer the following pattern for asserting exceptions that are expected to be thrown:

DatastoreException datastoreException = org.junit.Assert.assertThrows(DatastoreException.class, () -> datastore.update(ENTITY3));
com.google.common.truth.Truth.assertThat(datastoreException.getReason()).isEqualTo(NOT_FOUND.name());
com.google.common.truth.Truth.assertThat(datastoreException.getCode()).isEqualTo(5);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! I've made these updates.

@kolea2 kolea2 added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 25, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 25, 2024
@kolea2 kolea2 merged commit 4c2d4ce into googleapis:V3-experimental Apr 25, 2024
@kolea2 kolea2 deleted the http-errors branch April 25, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: datastore Issues related to the googleapis/java-datastore API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants