Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@GrpcExceptionHandler doesnot propagate the cause #1139

Open
lewimuchiri opened this issue Sep 3, 2024 · 0 comments
Open

@GrpcExceptionHandler doesnot propagate the cause #1139

lewimuchiri opened this issue Sep 3, 2024 · 0 comments
Labels
bug Something does not work as expected

Comments

@lewimuchiri
Copy link

lewimuchiri commented Sep 3, 2024

@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
@lewimuchiri lewimuchiri added the bug Something does not work as expected label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as expected
Projects
None yet
Development

No branches or pull requests

1 participant