-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Greetings!
First of all, very glad to see that gRPC is becoming supported by the Spring ecosystem.
I spent the day attempting to migrate to use this library and found that the GrpcExceptiionHandler was not working as I would have expected it to.
I have created a fork of this project and modified the grpc-reactor sample to demonstrate exactly what is going on here: https://github.com/svametcalf/spring-grpc/tree/reactor-error-handler. In short, I have registered the following exception handler:
@Bean
GrpcExceptionHandler grpcExceptionHandler() {
log.info("GrpcExceptionHandler");
return ex -> {
if(ex instanceof IllegalArgumentException ){
log.error("Error in grpc exception", ex);
return Status.INVALID_ARGUMENT.withDescription(ex.getMessage());
}
return Status.INTERNAL.withCause(ex).withDescription(ex.getMessage());
};
}I am getting the following responses when using grpcurl:
❯ grpcurl -d '{"name":"error"}' -plaintext localhost:9090 Simple.SayHello
ERROR:
Code: Unknown
Message: and
❯ grpcurl -d '{"name":"internal"}' -plaintext localhost:9090 Simple.SayHello
ERROR:
Code: Unknown
Message: Shouldn't those error codes be INVALID and INTERNAL respectively?
Metadata
Metadata
Assignees
Labels
No labels