Commit 5b6723fc3c7fd7813acd324b23ce66d4e52546b8

Authored by YunaiV
1 parent 3adfeb37

fix:【framework 框架】GlobalExceptionHandler 兼容更多 ServiceException 情况

yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/handler/GlobalExceptionHandler.java
... ... @@ -115,9 +115,6 @@ public class GlobalExceptionHandler {
115 115 if (ex instanceof AccessDeniedException) {
116 116 return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
117 117 }
118   - if (ex instanceof UncheckedExecutionException && ex.getCause() != ex) {
119   - return allExceptionHandler(request, ex.getCause());
120   - }
121 118 return defaultExceptionHandler(request, ex);
122 119 }
123 120  
... ... @@ -321,6 +318,12 @@ public class GlobalExceptionHandler {
321 318 */
322 319 @ExceptionHandler(value = Exception.class)
323 320 public CommonResult<?> defaultExceptionHandler(HttpServletRequest req, Throwable ex) {
  321 + // 特殊:如果是 ServiceException 的异常,则直接返回
  322 + // 例如说:https://gitee.com/zhijiantianya/yudao-cloud/issues/ICSSRM、https://gitee.com/zhijiantianya/yudao-cloud/issues/ICT6FM
  323 + if (ex.getCause() != null && ex.getCause() instanceof ServiceException) {
  324 + return serviceExceptionHandler((ServiceException) ex.getCause());
  325 + }
  326 +
324 327 // 情况一:处理表不存在的异常
325 328 CommonResult<?> tableNotExistsResult = handleTableNotExists(ex);
326 329 if (tableNotExistsResult != null) {
... ...