use of com.scalar.db.rpc.TransactionResponse in project scalardb by scalar-labs.
the class GrpcTransactionOnBidirectionalStream method throwIfErrorForCrud.
private void throwIfErrorForCrud(ResponseOrError responseOrError) throws CrudException {
if (responseOrError.isError()) {
finished.set(true);
Throwable error = responseOrError.getError();
if (error instanceof Error) {
throw (Error) error;
}
throw new CrudException("failed to execute crud", error);
}
TransactionResponse response = responseOrError.getResponse();
if (response.hasError()) {
TransactionResponse.Error error = response.getError();
switch(error.getErrorCode()) {
case INVALID_ARGUMENT:
throw new IllegalArgumentException(error.getMessage());
case CONFLICT:
throw new CrudConflictException(error.getMessage());
default:
throw new CrudException(error.getMessage());
}
}
}
Aggregations