fix:【framework 框架】GlobalExceptionHandler 兼容更多 ServiceException 情况
This commit is contained in:
@@ -115,9 +115,6 @@ public class GlobalExceptionHandler {
|
|||||||
if (ex instanceof AccessDeniedException) {
|
if (ex instanceof AccessDeniedException) {
|
||||||
return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
|
return accessDeniedExceptionHandler(request, (AccessDeniedException) ex);
|
||||||
}
|
}
|
||||||
if (ex instanceof UncheckedExecutionException && ex.getCause() != ex) {
|
|
||||||
return allExceptionHandler(request, ex.getCause());
|
|
||||||
}
|
|
||||||
return defaultExceptionHandler(request, ex);
|
return defaultExceptionHandler(request, ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +318,12 @@ public class GlobalExceptionHandler {
|
|||||||
*/
|
*/
|
||||||
@ExceptionHandler(value = Exception.class)
|
@ExceptionHandler(value = Exception.class)
|
||||||
public CommonResult<?> defaultExceptionHandler(HttpServletRequest req, Throwable ex) {
|
public CommonResult<?> defaultExceptionHandler(HttpServletRequest req, Throwable ex) {
|
||||||
|
// 特殊:如果是 ServiceException 的异常,则直接返回
|
||||||
|
// 例如说:https://gitee.com/zhijiantianya/yudao-cloud/issues/ICSSRM、https://gitee.com/zhijiantianya/yudao-cloud/issues/ICT6FM
|
||||||
|
if (ex.getCause() != null && ex.getCause() instanceof ServiceException) {
|
||||||
|
return serviceExceptionHandler((ServiceException) ex.getCause());
|
||||||
|
}
|
||||||
|
|
||||||
// 情况一:处理表不存在的异常
|
// 情况一:处理表不存在的异常
|
||||||
CommonResult<?> tableNotExistsResult = handleTableNotExists(ex);
|
CommonResult<?> tableNotExistsResult = handleTableNotExists(ex);
|
||||||
if (tableNotExistsResult != null) {
|
if (tableNotExistsResult != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user