@@ -290,7 +290,7 @@ public void mutateRow(
290290 client .dataClient ().mutateRow (mutation );
291291 } catch (ApiException e ) {
292292 responseObserver .onNext (
293- MutateRowResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
293+ MutateRowResult .newBuilder ().setStatus (convertStatus (e )).build ());
294294 responseObserver .onCompleted ();
295295 return ;
296296 } catch (StatusRuntimeException e ) {
@@ -343,7 +343,7 @@ public void bulkMutateRows(
343343 return ;
344344 } catch (ApiException e ) {
345345 responseObserver .onNext (
346- MutateRowsResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
346+ MutateRowsResult .newBuilder ().setStatus (convertStatus (e )).build ());
347347 responseObserver .onCompleted ();
348348 return ;
349349 } catch (StatusRuntimeException e ) {
@@ -396,7 +396,7 @@ public void readRow(ReadRowRequest request, StreamObserver<RowResult> responseOb
396396 }
397397 } catch (ApiException e ) {
398398 responseObserver .onNext (
399- RowResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
399+ RowResult .newBuilder ().setStatus (convertStatus (e )).build ());
400400 responseObserver .onCompleted ();
401401 return ;
402402 } catch (StatusRuntimeException e ) {
@@ -441,7 +441,7 @@ public void readRows(ReadRowsRequest request, StreamObserver<RowsResult> respons
441441 resultBuilder .setStatus (com .google .rpc .Status .getDefaultInstance ()).build ());
442442 } catch (ApiException e ) {
443443 responseObserver .onNext (
444- RowsResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
444+ RowsResult .newBuilder ().setStatus (convertStatus (e )).build ());
445445 responseObserver .onCompleted ();
446446 return ;
447447 } catch (StatusRuntimeException e ) {
@@ -466,6 +466,7 @@ public void readRows(ReadRowsRequest request, StreamObserver<RowsResult> respons
466466 responseObserver .onCompleted ();
467467 }
468468
469+
469470 /**
470471 * Helper method to convert row from type com.google.cloud.bigtable.data.v2.models.Row to type
471472 * com.google.bigtable.v2.Row. After conversion, row cells within the same column and family are
@@ -559,7 +560,7 @@ public void sampleRowKeys(
559560 keyOffsets = client .dataClient ().sampleRowKeys (tableId );
560561 } catch (ApiException e ) {
561562 responseObserver .onNext (
562- SampleRowKeysResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
563+ SampleRowKeysResult .newBuilder ().setStatus (convertStatus (e )).build ());
563564 responseObserver .onCompleted ();
564565 return ;
565566 } catch (StatusRuntimeException e ) {
@@ -599,7 +600,7 @@ public void checkAndMutateRow(
599600 matched = client .dataClient ().checkAndMutateRow (mutation );
600601 } catch (ApiException e ) {
601602 responseObserver .onNext (
602- CheckAndMutateRowResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
603+ CheckAndMutateRowResult .newBuilder ().setStatus (convertStatus (e )).build ());
603604 responseObserver .onCompleted ();
604605 return ;
605606 } catch (StatusRuntimeException e ) {
@@ -644,7 +645,7 @@ public void readModifyWriteRow(
644645 }
645646 } catch (ApiException e ) {
646647 responseObserver .onNext (
647- RowResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
648+ RowResult .newBuilder ().setStatus (convertStatus (e )).build ());
648649 responseObserver .onCompleted ();
649650 return ;
650651 } catch (StatusRuntimeException e ) {
@@ -701,7 +702,7 @@ public void executeQuery(
701702 return ;
702703 } catch (ApiException e ) {
703704 responseObserver .onNext (
704- ExecuteQueryResult .newBuilder ().setStatus (StatusProto . fromThrowable (e )).build ());
705+ ExecuteQueryResult .newBuilder ().setStatus (convertStatus (e )).build ());
705706 responseObserver .onCompleted ();
706707 return ;
707708 } catch (StatusRuntimeException e ) {
@@ -795,6 +796,18 @@ public ManagedChannelBuilder apply(ManagedChannelBuilder input) {
795796 .build ();
796797 }
797798
799+ // Cleanly forwards server errors through the test proxy. Internal client errors
800+ // are wrapped in an UNKNOWN status.
801+ private static com .google .rpc .Status convertStatus (ApiException e ) {
802+ com .google .rpc .Status status = StatusProto .fromThrowable (e );
803+ if (status != null ) {
804+ return status ;
805+ }
806+
807+ return com .google .rpc .Status .newBuilder ().setCode (e .getStatusCode ().getCode ().ordinal ()).setMessage (e .getMessage ())
808+ .build ();
809+ }
810+
798811 private CredentialsProvider getCredentialsProvider (String accessToken ) {
799812 if (accessToken .isEmpty ()) {
800813 return NoCredentialsProvider .create ();
0 commit comments