grpc-spring
grpc-spring copied to clipboard
请问异常处理能否提供demo
The context
- 请问异常处理的地方能否出一个demo。我服务端发的metadata,客户端总是接不到
- 异常处理时返回了Status,StatusRuntimeException、StatusException。可是客户端收到的都是StatusRuntimeException是否正常?
- 能否出一个教程去改造GrpcExceptionHandler?因为Spring的ExceptionHandler在捕获异常后可以处理成正常消息返回。我觉得大家还是很需要这种功能的。毕竟Grpc的异常处理能力确实不行。
The question
- 请问异常处理的地方能否出一个demo。我服务端发的metadata,客户端总是接不到
- 异常处理时返回了Status,StatusRuntimeException、StatusException。可是客户端收到的都是StatusRuntimeException是否正常?
- 能否出一个教程去改造GrpcExceptionHandler?因为Spring的ExceptionHandler在捕获异常后可以处理成正常消息返回。我觉得大家还是很需要这种功能的。毕竟Grpc的异常处理能力确实不行。
Stacktraces and logs
无
The application's environment
Which versions do you use?
- Spring (boot): 3.0.0
- grpc-java: 1.51.0
- protobuf: 3.21.9
- grpc-spring-boot-starter: 2.13.1.RELEASE
- protobuf-plugin: 0.6.1
- java: OpenJDK 18.0.2.1 64-Bit Zulu18.32+13-CA
Additional information
- Did it ever work before? 不行
- How can we reproduce it? 看demo
- Do you have a demo? 请看网址https://jidaojiuyou.lanzout.com/ipjQ70htu1qj
- May I ask if there is a demo for exception handling. The metadata sent by my server is always not received by the client
Only the tests: https://github.com/yidongnan/grpc-spring-boot-starter/blob/master/tests/src/test/java/net/devh/boot/grpc/test/advice/AdviceExceptionHandlingTest.java#L68
- Status, StatusRuntimeException, and StatusException are returned during exception handling. But is it normal for the client to receive StatusRuntimeException?
Yes, that is a grpc-java implementation decision, that I have no influence on.
- Can you make a tutorial to transform GrpcExceptionHandler? Because Spring's ExceptionHandler can process the exception and return it as a normal message. I think everyone still needs this feature. After all, the exception handling ability of Grpc is really not good.
That might be a though challenge (e.g. since you cannot really return any message as in spring-web). I will have a look at it.
thank you, i will try it first