Browse Source

修复 bug 35512

lyhzzz 2 năm trước cách đây
mục cha
commit
35ab8dec8d

+ 5 - 1
src/main/java/com/fdkankan/sale/exception/GlobalExceptionHandler.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.exc.InputCoercionException;
 import com.fdkankan.sale.common.ResultCode;
 import com.fdkankan.sale.common.ResultData;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.dao.DataIntegrityViolationException;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -23,7 +24,10 @@ public class GlobalExceptionHandler {
     @ExceptionHandler(value = Exception.class)
     public ResultData exceptionHandler(Exception e) throws Exception {
         log.error("服务错误:", e);
-        if(e .getCause().getMessage() != null && e.getCause().getMessage().contains("out of range of")){
+        if(e == null || e.getCause() == null || StringUtils.isBlank(e.getCause().getMessage())){
+            return ResultData.error( 500, "系统错误");
+        }
+        if(e.getCause().getMessage() != null && e.getCause().getMessage().contains("out of range of")){
             return ResultData.error(ResultCode.DATA_TOO_LONG);
         }
         return ResultData.error( 500, e.getCause().getMessage());

+ 1 - 1
src/main/java/com/fdkankan/sale/util/OrderListVo.java

@@ -50,7 +50,7 @@ public class OrderListVo {
             return;
         }
         HashMap<Integer,String> map = new HashMap<>();
-        for (int i = 0 ;i <=list.size();i ++){
+        for (int i = 0 ;i < list.size();i ++){
             Object o = list.get(i);
             String image = o.toString();
             map.put(i ,image);