use of io.grpc.StatusRuntimeException in project grpc-java by grpc.
the class ThriftUtilsTest method parseInvalid.
@Test
public void parseInvalid() throws Exception {
InputStream is = new ByteArrayInputStream(new byte[] { -127 });
try {
marshaller.parse(is);
fail("Expected exception");
} catch (StatusRuntimeException ex) {
assertEquals(Status.Code.INTERNAL, ex.getStatus().getCode());
assertTrue(ex.getCause() instanceof TException);
}
}
use of io.grpc.StatusRuntimeException in project core-java by SpineEventEngine.
the class ValidationFilter method reportMissingTenantId.
private void reportMissingTenantId(Command command, StreamObserver<Response> responseObserver) {
final CommandException noTenantDefined = InvalidCommandException.onMissingTenantId(command);
commandBus.commandStore().storeWithError(command, noTenantDefined);
final StatusRuntimeException exception = invalidArgumentWithCause(noTenantDefined, noTenantDefined.getError());
responseObserver.onError(exception);
}
use of io.grpc.StatusRuntimeException in project core-java by SpineEventEngine.
the class RequestValidator method feedToResponse.
private static void feedToResponse(InvalidRequestException cause, StreamObserver<?> responseObserver) {
final StatusRuntimeException validationException = invalidArgumentWithCause(cause, cause.getError());
responseObserver.onError(validationException);
}
use of io.grpc.StatusRuntimeException in project beam by apache.
the class BigtableServiceImpl method tableExists.
@Override
public boolean tableExists(String tableId) throws IOException {
try (BigtableSession session = new BigtableSession(options)) {
GetTableRequest getTable = GetTableRequest.newBuilder().setName(options.getInstanceName().toTableNameStr(tableId)).build();
session.getTableAdminClient().getTable(getTable);
return true;
} catch (StatusRuntimeException e) {
if (e.getStatus().getCode() == Code.NOT_FOUND) {
return false;
}
String message = String.format("Error checking whether table %s (BigtableOptions %s) exists", tableId, options);
LOG.error(message, e);
throw new IOException(message, e);
}
}
use of io.grpc.StatusRuntimeException in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method getIamPolicyExceptionTest.
@Test
@SuppressWarnings("all")
public void getIamPolicyExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockIAMPolicy.addException(exception);
try {
String formattedResource = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]").toString();
client.getIamPolicy(formattedResource);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations