Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use store_not_found metadata and appropriate exceptions #371

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading