You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/04/17 04:01:40 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1715: 如何把全局异常返回改成自己定义的json格式和信息?

liubao68 commented on issue #1715: 如何把全局异常返回改成自己定义的json格式和信息?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1715#issuecomment-615028241
 
 
   最新版本会对这个异常做一些处理,参考: 
   1. https://github.com/apache/servicecomb-java-chassis/pull/1699/files : 错误消息修改
   2. https://github.com/apache/servicecomb-java-chassis/pull/1687 业务抛出的所有异常都会经过 ExceptionToProducerResponseConverter 处理
   
   可以看下你的异常是哪里抛出来的,如果是业务抛出来的,参考 2 的示例,定制一个 ExceptionToProducerResponseConverter  即可。 如果是 handler 处理过程中抛出的, 可以写一个 ExceptionHanlder,放到所有 Hanlder 前面, 可以处理所有捕获到的异常。 实现 这个 handler 可以参考 https://docs.servicecomb.io/java-chassis/zh_CN/featured-topics/features/trace-id/ 这里的例子。 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services