Skip to content

@GrpcExceptionHandler doesnot propagate the cause #1139

@lewis-munene

Description

@lewis-munene
@GrpcAdvice
public class ExceptionHandler {

    @GrpcExceptionHandler(Exception.class)
    public StatusException handleGenericException(Exception e) {
        String message = StringUtils.hasText(e.getMessage())
            ? e.getMessage()
            : "An unexpected error occurred. Please try again later";

        return Status.INTERNAL.withDescription(message)
            .withCause(e)
            .asException();
    }

}

Given the above code, the cause is not propagated to client when the client catches the exception. The client finds it as null. It looks like it gets deleted somewhere before it gets to the client, so the withCause() call has no effect.

Which versions do you use?

  • Spring (boot): 3.2.8
  • grpc-spring-boot-starter: 2.1.5.RELEASE
  • java: version + architecture (64bit?): Java 21, 64bit architecture

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething does not work as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions