Bladeren bron

add some values in K8sApiException's codeMap and modify the SecretApiImpl.

马佳君 7 jaren geleden
bovenliggende
commit
8d3f624578

+ 2 - 1
src/main/java/nju/seec/SEECdemo/logic/api/k8s/exception/K8sApiException.java

@@ -35,8 +35,9 @@ public class K8sApiException extends Exception{
     static {
         codeMap.put(NAMESPACE_NOT_EXIST, "命名空间不存在");
         codeMap.put(DEPLOYMENT_NOT_EXIST, "部署不存在");
+        codeMap.put(SECRET_NOT_FOUND, "密钥不存在");
         codeMap.put(RESOURCE_QUOTA_NOT_EXIST, "资源限额不存在");
-
+        codeMap.put(SECRET_ALREADY_EXIST, "密钥已存在");
         codeMap.put(NAMESPACE_ALREADY_EXIST, "命名空间已经存在");
 
         codeMap.put(ILLEGAL_PARAMETER, "非法参数");

+ 3 - 3
src/main/java/nju/seec/SEECdemo/logic/api/k8s/impl/SecretApiImpl.java

@@ -58,7 +58,7 @@ public class SecretApiImpl implements SecretApi {
             } else if (e.getCode() == K8sApiException.SECRET_ALREADY_EXIST) {
                 throw new K8sApiException(K8sApiException.SECRET_ALREADY_EXIST);
             }else{
-                throw new K8sApiException(K8sApiException.SYSTEM_ERROR);
+                throw K8sApiException.K8s_SYSTEM_ERROR_EXCEPTION;
             }
         }
     }
@@ -98,7 +98,7 @@ public class SecretApiImpl implements SecretApi {
             if (e.getCode() == K8sApiException.NAMESPACE_NOT_EXIST) {
                 throw new K8sApiException(K8sApiException.NAMESPACE_NOT_EXIST);
             } else {
-                throw new K8sApiException(K8sApiException.SYSTEM_ERROR);
+                throw K8sApiException.K8s_SYSTEM_ERROR_EXCEPTION;
             }
         }
     }
@@ -138,7 +138,7 @@ public class SecretApiImpl implements SecretApi {
             if (e.getCode() == K8sApiException.SECRET_NOT_FOUND) {
                 throw new K8sApiException(K8sApiException.SECRET_NOT_FOUND);
             } else {
-                throw new K8sApiException(K8sApiException.SYSTEM_ERROR);
+                throw K8sApiException.K8s_SYSTEM_ERROR_EXCEPTION;
             }
         }
     }