Skip to content

Commit 1e9bd9a

Browse files
protobuf: expose Status specific Unwrapper
1 parent 9747994 commit 1e9bd9a

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

protobuf/src/main/java/io/grpc/protobuf/StatusProto.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,25 @@ public static com.google.rpc.Status fromThrowable(Throwable t) {
136136
while (cause != null) {
137137
if (cause instanceof StatusException) {
138138
StatusException e = (StatusException) cause;
139-
return toStatusProto(e.getStatus(), e.getTrailers());
139+
return fromStatusAndTrailers(e.getStatus(), e.getTrailers());
140140
} else if (cause instanceof StatusRuntimeException) {
141141
StatusRuntimeException e = (StatusRuntimeException) cause;
142-
return toStatusProto(e.getStatus(), e.getTrailers());
142+
return fromStatusAndTrailers(e.getStatus(), e.getTrailers());
143143
}
144144
cause = cause.getCause();
145145
}
146146
return null;
147147
}
148148

149+
/**
150+
* Extracts the google.rpc.Status from trailers, and makes sure they match the gRPC
151+
* {@code status}.
152+
*
153+
* @return the embedded google.rpc.Status or {@code null} if it is not present.
154+
* @since 1.10.0
155+
*/
149156
@Nullable
150-
private static com.google.rpc.Status toStatusProto(Status status, Metadata trailers) {
157+
public static com.google.rpc.Status fromStatusAndTrailers(Status status, Metadata trailers) {
151158
if (trailers != null) {
152159
com.google.rpc.Status statusProto = trailers.get(STATUS_DETAILS_KEY);
153160
if (statusProto != null) {

0 commit comments

Comments
 (0)