grpc-spring icon indicating copy to clipboard operation
grpc-spring copied to clipboard

请问异常处理能否提供demo

Open jidaojiuyou opened this issue 2 years ago • 2 comments

The context

  1. 请问异常处理的地方能否出一个demo。我服务端发的metadata,客户端总是接不到
  2. 异常处理时返回了Status,StatusRuntimeException、StatusException。可是客户端收到的都是StatusRuntimeException是否正常?
  3. 能否出一个教程去改造GrpcExceptionHandler?因为Spring的ExceptionHandler在捕获异常后可以处理成正常消息返回。我觉得大家还是很需要这种功能的。毕竟Grpc的异常处理能力确实不行。

The question

  1. 请问异常处理的地方能否出一个demo。我服务端发的metadata,客户端总是接不到
  2. 异常处理时返回了Status,StatusRuntimeException、StatusException。可是客户端收到的都是StatusRuntimeException是否正常?
  3. 能否出一个教程去改造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

jidaojiuyou avatar Dec 05 '22 02:12 jidaojiuyou

English


  • 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.

ST-DDT avatar Dec 05 '22 10:12 ST-DDT

thank you, i will try it first

jidaojiuyou avatar Dec 12 '22 07:12 jidaojiuyou