-
Notifications
You must be signed in to change notification settings - Fork 5
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
refactor: introduce Store(Item)?NotFoundException
classes
#360
Conversation
This PR detects when a `NOT_FOUND` gRPC error was specific to the storage client or not. For the storage client `NOT_FOUND`, there are two cases: the store was not found and the item was not found. To distinguish these two cases we use string matching on the grpcException message.
Not terribly important or urgent: we may consider organizing the various
|
Naming choices I made:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We'll have to be careful about building an exception hierarchy that includes cache exceptions, since we could technically introduce breaking changes if a call starts returning a different error type than before.
We also document changes to make in the immediate future.
The metadata should come from the exception trailers, not the request metadata.
if (errorCause == null) { | ||
// TODO remove once control service is updated to send "err" in metadata | ||
errorCause = grpcException.getMessage(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update this once the server is up to date.
if (errorCause.contains("element_not_found")) { | ||
return new StoreItemNotFoundException(grpcException, errorDetails); | ||
// TODO change once control service is updated to send "Store with name" in metadata | ||
} else if (errorCause.contains("Store with name")) { | ||
return new StoreNotFoundException(grpcException, errorDetails); | ||
} else { | ||
return new NotFoundException(grpcException, errorDetails); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update these once the server is up to date.
This PR detects when a
NOT_FOUND
gRPC error was specific to thestorage client or not. For the storage client
NOT_FOUND
, there aretwo cases: the store was not found and the item was not found.
To distinguish these two cases we use string matching on the
grpcException message.