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/07/10 03:13:48 UTC

[GitHub] [servicecomb-java-chassis] macosong opened a new issue #1879: Spring Validation验证抛出的异常无法捕获吗

macosong opened a new issue #1879:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1879


   我测试用的controller接口定义如下:
   `String getVerifyCode(@NotNull(message = "phone cannot be empty!") Long phone) throws Exception;`
   Long型变量为空时访问rest接口会抛出javax.validation.ConstraintViolationException
   但是我自定义的ExceptionToProducerResponseConverter类却无法捕捉到这个异常,convert方法中的异常处理逻辑并没有执行。
   请问这个问题怎么解决呢?谢谢
   


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



[GitHub] [servicecomb-java-chassis] macosong commented on issue #1879: Spring Validation验证抛出的异常无法捕获吗

Posted by GitBox <gi...@apache.org>.
macosong commented on issue #1879:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1879#issuecomment-656520144


   已解决,谢谢。


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



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1879: Spring Validation验证抛出的异常无法捕获吗

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1879:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1879#issuecomment-656519088


   如果过这样的话, 覆盖下 getOrder 方法。


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



[GitHub] [servicecomb-java-chassis] macosong commented on issue #1879: Spring Validation验证抛出的异常无法捕获吗

Posted by GitBox <gi...@apache.org>.
macosong commented on issue #1879:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1879#issuecomment-656512002


   
   
   
   > java-chassis包含了`ConstraintViolationExceptionToProducerResponseConverter`,看下是否被这个处理了。 或者是不是没有配置SPI的service文件,导致新加的配置不生效。
   
   有配置service文件,应该是被`ConstraintViolationExceptionToProducerResponseConverte`处理了,所以我自定义的converter类没有生效。
   因为要修改它默认返回的Response,所以可能让自定义的Converter需要覆盖掉这个类,请问有什么办法解决吗?谢谢


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



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #1879: Spring Validation验证抛出的异常无法捕获吗

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1879:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1879#issuecomment-656503723


   java-chassis包含了`ConstraintViolationExceptionToProducerResponseConverter`,看下是否被这个处理了。 或者是不是没有配置SPI的service文件,导致新加的配置不生效。 


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