use of com.google.rpc.BadRequest in project titus-control-plane by Netflix.
the class TestStreamObserver method exceptionMapper.
private RuntimeException exceptionMapper(Throwable error) {
if (error instanceof StatusRuntimeException) {
StatusRuntimeException e = (StatusRuntimeException) error;
String errorMessage = "GRPC status " + e.getStatus() + ": " + e.getTrailers().get(ErrorResponses.KEY_TITUS_ERROR_REPORT);
Optional<BadRequest> badRequest = GrpcClientErrorUtils.getDetail(e, BadRequest.class);
if (badRequest.isPresent()) {
return new RuntimeException(errorMessage + ". Invalid field values: " + badRequest, error);
}
return new RuntimeException(errorMessage, error);
}
return new RuntimeException(error.getMessage(), error);
}
Aggregations