mirror of
https://gitee.com/youlaitech/youlai-mall.git
synced 2024-12-22 20:54:26 +08:00
refactor: 未知异常日志log添加
This commit is contained in:
parent
d3051c4cc8
commit
fdfcd93b4b
@ -30,12 +30,11 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局系统异常处理
|
* 全局系统异常处理
|
||||||
|
* <p>
|
||||||
* 调整异常处理的HTTP状态码,丰富异常处理类型
|
* 调整异常处理的HTTP状态码,丰富异常处理类型
|
||||||
*
|
*
|
||||||
* @author hxrui
|
|
||||||
* @author Gadfly
|
* @author Gadfly
|
||||||
* @date 2020-02-25 13:54
|
* @date 2020-02-25 13:54
|
||||||
* <p>
|
|
||||||
**/
|
**/
|
||||||
@RestControllerAdvice
|
@RestControllerAdvice
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -158,8 +157,8 @@ public class GlobalExceptionHandler {
|
|||||||
@ResponseStatus(HttpStatus.FORBIDDEN)
|
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||||
@ExceptionHandler(SQLSyntaxErrorException.class)
|
@ExceptionHandler(SQLSyntaxErrorException.class)
|
||||||
public <T> Result<T> processSQLSyntaxErrorException(SQLSyntaxErrorException e) {
|
public <T> Result<T> processSQLSyntaxErrorException(SQLSyntaxErrorException e) {
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
String errorMsg = e.getMessage();
|
String errorMsg = e.getMessage();
|
||||||
|
log.error(errorMsg);
|
||||||
if (StrUtil.isNotBlank(errorMsg) && errorMsg.contains("denied to user")) {
|
if (StrUtil.isNotBlank(errorMsg) && errorMsg.contains("denied to user")) {
|
||||||
return Result.failed("数据库用户无操作权限,建议本地搭建数据库环境");
|
return Result.failed("数据库用户无操作权限,建议本地搭建数据库环境");
|
||||||
} else {
|
} else {
|
||||||
@ -186,7 +185,7 @@ public class GlobalExceptionHandler {
|
|||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
@ExceptionHandler(ApiException.class)
|
@ExceptionHandler(ApiException.class)
|
||||||
public <T> Result<T> handleBizException(ApiException e) {
|
public <T> Result<T> handleBizException(ApiException e) {
|
||||||
log.error("业务异常,异常原因:{}", e.getMessage(), e);
|
log.error("API异常:{}", e.getMessage(), e);
|
||||||
if (e.getResultCode() != null) {
|
if (e.getResultCode() != null) {
|
||||||
return Result.failed(e.getResultCode());
|
return Result.failed(e.getResultCode());
|
||||||
}
|
}
|
||||||
@ -196,7 +195,8 @@ public class GlobalExceptionHandler {
|
|||||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||||
@ExceptionHandler(Exception.class)
|
@ExceptionHandler(Exception.class)
|
||||||
public <T> Result<T> handleException(Exception e) {
|
public <T> Result<T> handleException(Exception e) {
|
||||||
return Result.failed(e.getLocalizedMessage());
|
log.error("未知异常:{}", e.getMessage());
|
||||||
|
return Result.failed(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user