Skip to content

Commit

Permalink
fix: use store_not_found metadata and appropriate exceptions
Browse files Browse the repository at this point in the history
Update the client to read `store_not_found` metadata to distinguish
cache vs store not found.
  • Loading branch information
malandis committed Jun 27, 2024
1 parent a6b9f09 commit ee6cab0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import momento.sdk.PreviewStorageClient;
import momento.sdk.auth.CredentialProvider;
import momento.sdk.config.StorageConfigurations;
import momento.sdk.exceptions.CacheNotFoundException;
import momento.sdk.exceptions.StoreNotFoundException;
import momento.sdk.responses.storage.DeleteResponse;
import momento.sdk.responses.storage.GetResponse;
import momento.sdk.responses.storage.PutResponse;
Expand Down Expand Up @@ -112,11 +112,11 @@ public void badStoreNameReturnsError() {

final GetResponse getResponse = client.get(storeName, "").join();
assertThat(getResponse).isInstanceOf(GetResponse.Error.class);
assertThat(((GetResponse.Error) getResponse)).hasCauseInstanceOf(CacheNotFoundException.class);
assertThat(((GetResponse.Error) getResponse)).hasCauseInstanceOf(StoreNotFoundException.class);

final PutResponse putResponse = client.put(storeName, "", "").join();
assertThat(putResponse).isInstanceOf(PutResponse.Error.class);
assertThat(((PutResponse.Error) putResponse)).hasCauseInstanceOf(CacheNotFoundException.class);
assertThat(((PutResponse.Error) putResponse)).hasCauseInstanceOf(StoreNotFoundException.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static SdkException convert(Throwable e, Metadata metadata) {
case NOT_FOUND:
if (errorCause.contains("item_not_found")) {
return new StoreItemNotFoundException(grpcException, errorDetails);
} else if (errorCause.contains("Store with name")) {
} else if (errorCause.contains("store_not_found")) {
return new StoreNotFoundException(grpcException, errorDetails);
} else {
return new CacheNotFoundException(grpcException, errorDetails);
Expand Down

0 comments on commit ee6cab0

Please sign in to comment.