Skip to content

add serviceclient exceptions #989

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

Conversation

shijiesheng
Copy link
Member

What changed?

  • added all exceptions to match thrift exceptions
  • added ErrorMapper which maps StatusRuntimeException to ServiceClientException

Why?

thrift exceptions are used across Java SDK. It's easier to abstract the protocol level error handling by introducing internal exception layer

How did you test it?

Potential risks

Release notes

Documentation Changes

@@ -0,0 +1,4 @@
package com.uber.cadence.serviceclient.exceptions;

public class QueryFailedException extends ServiceClientException {
Copy link
Member

Choose a reason for hiding this comment

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

This is unused

Copy link
Member Author

Choose a reason for hiding this comment

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

deleted

@@ -0,0 +1,4 @@
package com.uber.cadence.serviceclient.exceptions;

public class StickyWorkerUnavailableException extends ServiceClientException {
Copy link
Member

Choose a reason for hiding this comment

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

This is unused and I don't think can actually propagate to the client

Copy link
Member Author

Choose a reason for hiding this comment

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

deleted


Status status = StatusProto.fromThrowable(e);
if (status == null || status.getDetailsCount() == 0) {
return new ServiceClientException("empty status or status with empty details", e);
Copy link
Member

Choose a reason for hiding this comment

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

Nit: When can this happen? What kind of exception does GRPC throw if we have a connection issue rather than an error returned by the server?

Copy link
Member Author

Choose a reason for hiding this comment

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

Server controls whether to pass details. https://github.com/uber/cadence/blob/f4e219ae4248552e53a8ba57036b9af62485221b/common/types/mapper/proto/errors.go#L274
I've simplified the logic to handle such cases.

@shijiesheng shijiesheng merged commit adcc039 into cadence-workflow:feature/issue-985/thrift-deprecation Apr 9, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants