ソースを参照

优化操作异常时返回报错内容

zhaojinyu 6 日 前
コミット
aaad4dafc3

+ 1 - 1
base-modules/service-file/src/main/java/com/ruoyi/file/controller/FileUpdateInfoController.java

@@ -45,7 +45,7 @@ public class FileUpdateInfoController {
             fileUpdateInfoService.performFileUpdate(id);
             fileUpdateInfoService.performFileUpdate(id);
             return ApiResult.success("文件更新成功");
             return ApiResult.success("文件更新成功");
         } catch (Exception e) {
         } catch (Exception e) {
-            return ApiResult.error("文件更新失败: " + e.getMessage());
+            return ApiResult.error("文件更新失败" + e.getMessage());
         }
         }
     }
     }
 
 

+ 7 - 7
base-modules/service-file/src/main/java/com/ruoyi/file/service/impl/FileUpdateInfoServiceImpl.java

@@ -129,7 +129,7 @@ public class FileUpdateInfoServiceImpl implements FileUpdateInfoService {
             if (!backupDir.exists()) {
             if (!backupDir.exists()) {
                 boolean created = backupDir.mkdirs();
                 boolean created = backupDir.mkdirs();
                 if (!created) {
                 if (!created) {
-                    throw new IOException("无法创建备份目录: " + backupDirPath);
+                    throw new IOException("无法创建备份目录");
                 }
                 }
             }
             }
 
 
@@ -163,11 +163,11 @@ public class FileUpdateInfoServiceImpl implements FileUpdateInfoService {
             controlApplication(fileName, "restart");
             controlApplication(fileName, "restart");
 
 
         } catch (FileNotFoundException e) {
         } catch (FileNotFoundException e) {
-            throw new Exception("文件未找到: " + localFilePath + ",原因: " + e.getMessage(), e);
+            throw new Exception("原因: " + e.getMessage(), e);
         } catch (IOException e) {
         } catch (IOException e) {
-            throw new Exception("文件写入失败: " + localFilePath + ",原因: " + e.getMessage(), e);
+            throw new Exception("原因: " + e.getMessage(), e);
         } catch (Exception e) {
         } catch (Exception e) {
-            throw new Exception("文件更新失败: " + localFilePath + ",原因: " + e.getMessage(), e);
+            throw new Exception("原因: 远程仓库未找到服务包");
         }
         }
     }
     }
 
 
@@ -176,10 +176,10 @@ public class FileUpdateInfoServiceImpl implements FileUpdateInfoService {
         Path path = Paths.get(localFilePath);
         Path path = Paths.get(localFilePath);
         try {
         try {
             Files.copy(url.openStream(), path, StandardCopyOption.REPLACE_EXISTING);
             Files.copy(url.openStream(), path, StandardCopyOption.REPLACE_EXISTING);
-            System.out.println("文件下载成功: " + localFilePath);
+            System.out.println("文件下载成功");
         } catch (IOException e) {
         } catch (IOException e) {
-            System.err.println("文件下载失败: " + localFilePath + ",原因: " + e.getMessage());
-            throw new Exception("文件下载失败: " + localFilePath, e);
+            System.err.println("文件下载失败" + ",原因: " + e.getMessage());
+            throw new Exception("文件下载失败");
         }
         }
     }
     }