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/02/21 07:30:39 UTC

[GitHub] [servicecomb-java-chassis] Caixinyang opened a new issue #1587: @RestControllerAdvice配置失效问题

Caixinyang opened a new issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587
 
 
   配置了如下全局异常捕捉:
   	// 处理请求参数格式错误 @RequestParam上validate失败后抛出的异常是javax.validation.ConstraintViolationException
   	@ExceptionHandler(ConstraintViolationException.class)
   	@ResponseBody
   	@ResponseStatus(HttpStatus.BAD_REQUEST)
   	public ResponseEntity<String> ConstraintViolationExceptionHandler(ConstraintViolationException exception) {
   		return ResponseEntity.status(HttpStatus.BAD_REQUEST)
   				.body("error, class A");
   	}
   实际调接口返回:
   {
       "message": "[ConstraintViolationImpl{interpolatedMessage='page should not less 1', propertyPath=getResponse1.page, rootBeanClass=class com.huaweicloud.app.manage.controller.AController$$EnhancerBySpringCGLIB$$38ac2b26, messageTemplate='page should not less 1'}]"
   }

----------------------------------------------------------------
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 edited a comment on issue #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
liubao68 edited a comment on issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587#issuecomment-589579079
 
 
   看起来是和 spring boot 的功能混淆了。 可以先参考一下介绍
   * [ java chassis SpringMVC的差异](https://docs.servicecomb.io/java-chassis/zh_CN/build-provider/springmvc/#servicecombspring-mvc)
   * [运行时差异](https://docs.servicecomb.io/java-chassis/zh_CN/using-java-chassis-in-spring-boot/introduction/)
   
   java chassis的异常处理不经过 `@ExceptionHandler`, [参考 ](https://docs.servicecomb.io/java-chassis/zh_CN/general-development/error-handling/) 

----------------------------------------------------------------
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] Caixinyang commented on issue #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
Caixinyang commented on issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587#issuecomment-590650984
 
 
   您好,我参考你提供的文档配置了ExceptionToProducerResponseConverter<ConstraintViolationException>捕捉到了@RequestParam异常。但是@RequestHeader异常不住不到,我尝试增加了ExceptionToProducerResponseConverter<InvocationException>,
   ExceptionToProducerResponseConverter<Exception>
   ExceptionToProducerResponseConverter<ServletRequestBindingException>
   ExceptionToProducerResponseConverter<UnsatisfiedServletRequestParameterException>等
   但是结果抓不到@RequestHeader的异常:
   org.apache.servicecomb.swagger.invocation.exception.InvocationException: InvocationException: code=400;msg=CommonExceptionData [message=Parameter is not valid for operation [application-manage.IefAppTemplateController.getAppTemplateList]. Parameter is [X-Auth-Token]. Processor is [header].]
   

----------------------------------------------------------------
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] Caixinyang commented on issue #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
Caixinyang commented on issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587#issuecomment-590651343
 
 
   您好,我参考你提供的文档配置了ExceptionToProducerResponseConverter捕捉到了@RequestParam异常。但是@RequestHeader异常不住不到,我尝试增加了对ServletRequestBindingException、UnsatisfiedServletRequestParameterException、Exception等异常的捕捉。
   但是结果都抓不到@RequestHeader的异常:
   org.apache.servicecomb.swagger.invocation.exception.InvocationException: InvocationException: code=400;msg=CommonExceptionData [message=Parameter is not valid for operation [application-manage.IefAppTemplateController.getAppTemplateList]. Parameter is [X-Auth-Token]. Processor is [header].]

----------------------------------------------------------------
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] Caixinyang commented on issue #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
Caixinyang commented on issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587#issuecomment-589595387
 
 
   OK

----------------------------------------------------------------
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 #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587#issuecomment-589579079
 
 
   看起来是和 spring boot 的功能混淆了。 可以先参考一下介绍
   * [ java chassis SpringMVC的差异](https://docs.servicecomb.io/java-chassis/zh_CN/build-provider/springmvc/#servicecombspring-mvc)
   * [运行时差异](https://docs.servicecomb.io/java-chassis/zh_CN/using-java-chassis-in-spring-boot/introduction/)

----------------------------------------------------------------
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] Caixinyang removed a comment on issue #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
Caixinyang removed a comment on issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587#issuecomment-590650984
 
 
   您好,我参考你提供的文档配置了ExceptionToProducerResponseConverter<ConstraintViolationException>捕捉到了@RequestParam异常。但是@RequestHeader异常不住不到,我尝试增加了ExceptionToProducerResponseConverter<InvocationException>,
   ExceptionToProducerResponseConverter<Exception>
   ExceptionToProducerResponseConverter<ServletRequestBindingException>
   ExceptionToProducerResponseConverter<UnsatisfiedServletRequestParameterException>等
   但是结果抓不到@RequestHeader的异常:
   org.apache.servicecomb.swagger.invocation.exception.InvocationException: InvocationException: code=400;msg=CommonExceptionData [message=Parameter is not valid for operation [application-manage.IefAppTemplateController.getAppTemplateList]. Parameter is [X-Auth-Token]. Processor is [header].]
   

----------------------------------------------------------------
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] Caixinyang closed issue #1587: @RestControllerAdvice配置失效问题

Posted by GitBox <gi...@apache.org>.
Caixinyang closed issue #1587: @RestControllerAdvice配置失效问题
URL: https://github.com/apache/servicecomb-java-chassis/issues/1587
 
 
   

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