feat: 优化错误提示
This commit is contained in:
parent
1b3e5cf7c2
commit
b6ec959050
|
|
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|||
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -24,6 +25,12 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
public class GlobalRestControllerAdvice {
|
||||
|
||||
@ExceptionHandler(SQLException.class)
|
||||
public ApiResult<Void> handleSQLException(SQLException ex) {
|
||||
log.error("数据库错误: ", ex);
|
||||
return ApiResult.error(STATE.BusinessError,"数据库错误");
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ApiResult<Void> handleAllExceptions(Exception ex) {
|
||||
log.error("服务器内部错误: ", ex);
|
||||
|
|
|
|||
Loading…
Reference in New Issue