Skip to content

GrpcExceptionHandler does not seem to be called when using Reactor generated stubs #143

@svametcalf

Description

@svametcalf

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions