完善 Dubbo Provider 统一异常过滤器

This commit is contained in:
YunaiV
2020-07-17 20:59:47 +08:00
parent e3f2e15c43
commit c5596919f5
3 changed files with 42 additions and 33 deletions

View File

@@ -155,7 +155,7 @@ public class GlobalExceptionHandler {
*/
@ExceptionHandler(value = Exception.class)
public CommonResult defaultExceptionHandler(HttpServletRequest req, Throwable e) {
logger.error("[exceptionHandler]", e);
logger.error("[defaultExceptionHandler]", e);
// 插入异常日志
SystemExceptionLogCreateDTO exceptionLog = new SystemExceptionLogCreateDTO();
try {
@@ -166,7 +166,7 @@ public class GlobalExceptionHandler {
// 执行插入 exceptionLog
addExceptionLog(exceptionLog);
} catch (Throwable th) {
logger.error("[exceptionHandler][插入访问日志({}) 发生异常({})", JSON.toJSONString(exceptionLog), ExceptionUtils.getRootCauseMessage(th));
logger.error("[defaultExceptionHandler][插入访问日志({}) 发生异常({})", JSON.toJSONString(exceptionLog), ExceptionUtils.getRootCauseMessage(th));
}
// 返回 ERROR CommonResult
return CommonResult.error(GlobalErrorCodeEnum.INTERNAL_SERVER_ERROR.getCode(), GlobalErrorCodeEnum.INTERNAL_SERVER_ERROR.getMessage());