mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
【功能优化】全局:简化 GlobalExceptionHandler 对 ServiceException 的打印
This commit is contained in:
parent
047051e008
commit
a8fc7982ff
@ -219,9 +219,11 @@ public class GlobalExceptionHandler {
|
||||
*/
|
||||
@ExceptionHandler(value = ServiceException.class)
|
||||
public CommonResult<?> serviceExceptionHandler(ServiceException ex) {
|
||||
// 不包含的时候,才进行打印,避免 ex 堆栈过多
|
||||
if (!IGNORE_ERROR_MESSAGES.contains(ex.getMessage())) {
|
||||
// 不包含的时候,才进行打印,避免 ex 堆栈过多
|
||||
log.info("[serviceExceptionHandler]", ex);
|
||||
// 即使打印,也只打印第一层 StackTraceElement,并且使用 warn 在控制台输出,更容易看到
|
||||
StackTraceElement[] stackTrace = ex.getStackTrace();
|
||||
log.warn("[serviceExceptionHandler]\n\t{}", stackTrace[0]);
|
||||
}
|
||||
return CommonResult.error(ex.getCode(), ex.getMessage());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user