Skip to content

Commit d4d746f

Browse files
authored
handle proto errors for domain APIs (#689)
1 parent ebc37ea commit d4d746f

File tree

1 file changed

+46
-21
lines changed

1 file changed

+46
-21
lines changed

src/main/java/com/uber/cadence/internal/compatibility/Thrift2ProtoAdapter.java

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,51 +118,76 @@ public Thrift2ProtoAdapter(IGrpcServiceStubs grpcServiceStubs) {
118118
public void RegisterDomain(RegisterDomainRequest registerRequest)
119119
throws BadRequestError, DomainAlreadyExistsError, ServiceBusyError,
120120
ClientVersionNotSupportedError, TException {
121-
grpcServiceStubs
122-
.domainBlockingStub()
123-
.registerDomain(RequestMapper.registerDomainRequest(registerRequest));
121+
try {
122+
grpcServiceStubs
123+
.domainBlockingStub()
124+
.registerDomain(RequestMapper.registerDomainRequest(registerRequest));
125+
} catch (StatusRuntimeException e) {
126+
convertAndThrowStatusException(e);
127+
throw e;
128+
}
124129
}
125130

126131
@Override
127132
public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
128133
throws BadRequestError, EntityNotExistsError, ServiceBusyError,
129134
ClientVersionNotSupportedError, TException {
130-
com.uber.cadence.api.v1.DescribeDomainResponse response =
131-
grpcServiceStubs
132-
.domainBlockingStub()
133-
.describeDomain(RequestMapper.describeDomainRequest(describeRequest));
134-
return ResponseMapper.describeDomainResponse(response);
135+
try {
136+
com.uber.cadence.api.v1.DescribeDomainResponse response =
137+
grpcServiceStubs
138+
.domainBlockingStub()
139+
.describeDomain(RequestMapper.describeDomainRequest(describeRequest));
140+
return ResponseMapper.describeDomainResponse(response);
141+
} catch (StatusRuntimeException e) {
142+
convertAndThrowStatusException(e);
143+
throw e;
144+
}
135145
}
136146

137147
@Override
138148
public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
139149
throws BadRequestError, EntityNotExistsError, ServiceBusyError,
140150
ClientVersionNotSupportedError, TException {
141-
com.uber.cadence.api.v1.ListDomainsResponse response =
142-
grpcServiceStubs
143-
.domainBlockingStub()
144-
.listDomains(RequestMapper.listDomainsRequest(listRequest));
145-
return ResponseMapper.listDomainsResponse(response);
151+
try {
152+
com.uber.cadence.api.v1.ListDomainsResponse response =
153+
grpcServiceStubs
154+
.domainBlockingStub()
155+
.listDomains(RequestMapper.listDomainsRequest(listRequest));
156+
return ResponseMapper.listDomainsResponse(response);
157+
} catch (StatusRuntimeException e) {
158+
convertAndThrowStatusException(e);
159+
throw e;
160+
}
146161
}
147162

148163
@Override
149164
public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest)
150165
throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
151166
ClientVersionNotSupportedError, TException {
152-
com.uber.cadence.api.v1.UpdateDomainResponse response =
153-
grpcServiceStubs
154-
.domainBlockingStub()
155-
.updateDomain(RequestMapper.updateDomainRequest(updateRequest));
156-
return ResponseMapper.updateDomainResponse(response);
167+
try {
168+
com.uber.cadence.api.v1.UpdateDomainResponse response =
169+
grpcServiceStubs
170+
.domainBlockingStub()
171+
.updateDomain(RequestMapper.updateDomainRequest(updateRequest));
172+
return ResponseMapper.updateDomainResponse(response);
173+
} catch (StatusRuntimeException e) {
174+
convertAndThrowStatusException(e);
175+
throw e;
176+
}
157177
}
158178

159179
@Override
160180
public void DeprecateDomain(DeprecateDomainRequest deprecateRequest)
161181
throws BadRequestError, EntityNotExistsError, ServiceBusyError, DomainNotActiveError,
162182
ClientVersionNotSupportedError, TException {
163-
grpcServiceStubs
164-
.domainBlockingStub()
165-
.deprecateDomain(RequestMapper.deprecateDomainRequest(deprecateRequest));
183+
try {
184+
grpcServiceStubs
185+
.domainBlockingStub()
186+
.deprecateDomain(RequestMapper.deprecateDomainRequest(deprecateRequest));
187+
} catch (StatusRuntimeException e) {
188+
convertAndThrowStatusException(e);
189+
throw e;
190+
}
166191
}
167192

168193
@Override

0 commit comments

Comments
 (0)