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 03:21:42 UTC

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

foodjth opened a new issue #1715: 如何把全局异常返回改成自己定义的json格式和信息?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1715
 
 
   {
       "message": "Cse Internal Bad Request"
   }
   
   如何把这个返回改成自定义的格式和信息?求解!!!!!!!!!!!!!!!!!!!!!

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

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

Posted by GitBox <gi...@apache.org>.
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

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

Posted by GitBox <gi...@apache.org>.
foodjth commented on issue #1715: 如何把全局异常返回改成自己定义的json格式和信息?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1715#issuecomment-615037177
 
 
   > 最新版本会对这个异常做一些处理,参考:
   > 
   > 1. https://github.com/apache/servicecomb-java-chassis/pull/1699/files : 错误消息修改
   > 2. #1687 业务抛出的所有异常都会经过 ExceptionToProducerResponseConverter 处理
   > 
   > 可以看下你的异常是哪里抛出来的,如果是业务抛出来的,参考 2 的示例,定制一个 ExceptionToProducerResponseConverter 即可。 如果是 handler 处理过程中抛出的, 可以写一个 ExceptionHanlder,放到所有 Hanlder 前面, 可以处理所有捕获到的异常。 实现 这个 handler 可以参考 https://docs.servicecomb.io/java-chassis/zh_CN/featured-topics/features/trace-id/ 这里的例子。
   
   老师你好,我是用edge做api网关,实现一个handler做鉴权,如果鉴权不通过就抛自定义异常,然后想根据异常类型返回不同的json提示;您看我这样可以吗?您说的是再实现一个异常handler,会捕获到我前面实现的鉴权handler抛出的异常?
   

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

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

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1715: 如何把全局异常返回改成自己定义的json格式和信息?
URL: https://github.com/apache/servicecomb-java-chassis/issues/1715#issuecomment-615116673
 
 
   可以捕获到的。如果仅仅处理一个接口的异常, 你的这个鉴权 handler 也是可以自己处理的。

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