From aeb5f7c2e17dc6595352286e62c8b97ee624ba68 Mon Sep 17 00:00:00 2001 From: Tang Cheng Date: Wed, 19 Jun 2019 11:46:20 +0800 Subject: [PATCH] =?utf8?q?chore:=E6=94=B9=E8=BF=9B=E7=B3=BB=E7=BB=9F?= =?utf8?q?=E5=AF=B9=E6=9C=AA=E5=A4=84=E7=90=86=E5=BC=82=E5=B8=B8=E4=BF=A1?= =?utf8?q?=E6=81=AF=E7=9A=84=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/com/supwisdom/dlpay/api/advices.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt index 5dff2a53..0a893ea3 100644 --- a/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt +++ b/src/main/kotlin/com/supwisdom/dlpay/api/advices.kt @@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity import org.springframework.stereotype.Component import org.springframework.web.bind.annotation.ExceptionHandler import org.springframework.web.bind.annotation.RestControllerAdvice +import java.lang.reflect.UndeclaredThrowableException import javax.servlet.http.HttpServletRequest @@ -24,16 +25,17 @@ class RestControllerAdvice { @ExceptionHandler fun handleException(ex: Exception, request: HttpServletRequest): ResponseEntity { logger.error { "Request unhandler exception, url<${request.requestURI}>, ex<${ex.cause}>" } - if(ex is RequestParamCheckException){ + val undeclared = if (ex is UndeclaredThrowableException) ex.undeclaredThrowable else ex + if (undeclared is RequestParamCheckException) { return ResponseEntity.ok(ResponseBodyBuilder.create() - .requestException(ex, "请求参数错误")) - }else if(ex is TransactionException){ + .requestException(undeclared, "请求参数错误")) + } else if (undeclared is TransactionException) { return ResponseEntity.ok(ResponseBodyBuilder.create() - .transException(ex, "业务处理错误")) + .transException(undeclared, "业务处理错误")) } return ResponseEntity.ok().body(ResponseBodyBuilder.create() - .exception(TradeErrorCode.BUSINESS_DEAL_ERROR, ex.cause,"业务处理报错")) + .exception(TradeErrorCode.BUSINESS_DEAL_ERROR, undeclared, "业务处理报错")) } } -- 2.17.1