Skip to content

Commit 6cd7250

Browse files
committed
extend to accept Status return type
1 parent f0bae7f commit 6cd7250

File tree

1 file changed

+6
-0
lines changed
  • grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/exceptionhandling

1 file changed

+6
-0
lines changed

grpc-server-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/server/service/exceptionhandling/GrpcExceptionAspect.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3232
import org.springframework.stereotype.Component;
3333

34+
import io.grpc.Status;
3435
import io.grpc.stub.StreamObserver;
3536
import lombok.extern.slf4j.Slf4j;
3637

@@ -138,6 +139,11 @@ private Class<?> convertToClass(Parameter parameter) {
138139
}
139140

140141
private Throwable castToThrowable(Object statusThrowable) {
142+
143+
if (statusThrowable instanceof Status) {
144+
Status statusToBeWrapped = (Status) statusThrowable;
145+
return statusToBeWrapped.asRuntimeException();
146+
}
141147
return Optional.of(statusThrowable)
142148
.filter(thrbl -> thrbl instanceof Throwable)
143149
.map(thrbl -> (Throwable) thrbl)

0 commit comments

Comments
 (0)