From 3ed2627f7c05e8eaa4559371f9d6d2cb71aa4275 Mon Sep 17 00:00:00 2001
From: java110 <928255095@qq.com>
Date: 星期日, 12 九月 2021 14:11:08 +0800
Subject: [PATCH] 优化刷新缓存功能

---
 java110-utils/src/main/java/com/java110/utils/exception/CmdException.java |   52 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/java110-utils/src/main/java/com/java110/utils/exception/CmdException.java b/java110-utils/src/main/java/com/java110/utils/exception/CmdException.java
index 817f64b..574f70e 100644
--- a/java110-utils/src/main/java/com/java110/utils/exception/CmdException.java
+++ b/java110-utils/src/main/java/com/java110/utils/exception/CmdException.java
@@ -2,6 +2,7 @@
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.java110.utils.constant.ResponseConstant;
 
 import java.io.PrintStream;
 import java.io.PrintWriter;
@@ -16,10 +17,12 @@
     private Result result;
     private Throwable cause = this;
 
-    public CmdException(){}
+    public CmdException() {
+    }
 
     /**
      * 鏋勯�犳柟娉�
+     *
      * @param result 杩斿洖鍊�
      * @param cause  寮傚父鍫嗘爤
      */
@@ -30,6 +33,17 @@
 
     /**
      * 鏋勯�犳柟娉�
+     *
+     * @param msg 閿欒娑堟伅
+     */
+    public CmdException(String msg) {
+        super(msg);
+        this.result = new Result(ResponseConstant.RESULT_CODE_ERROR, msg);
+    }
+
+    /**
+     * 鏋勯�犳柟娉�
+     *
      * @param code 杩斿洖鐮�
      * @param msg  閿欒娑堟伅
      */
@@ -45,6 +59,7 @@
 
     /**
      * 鏋勯�犳柟娉�
+     *
      * @param result 杩斿洖鍊�
      * @param detail 鍏蜂綋鐨勮繑鍥炴秷鎭�
      */
@@ -55,6 +70,7 @@
 
     /**
      * 鏋勯�犳柟娉�
+     *
      * @param result 杩斿洖鍊�
      * @param detail 鍏蜂綋鐨勮繑鍥炴秷鎭�
      * @param cause  寮傚父鍫嗘爤
@@ -66,52 +82,55 @@
 
     /**
      * 鏋勯�犳柟娉�
-     * @param code	杩斿洖鐮�
-     * @param msg	杩斿洖娑堟伅
+     *
+     * @param code  杩斿洖鐮�
+     * @param msg   杩斿洖娑堟伅
      * @param cause 寮傚父鍫嗘爤
      */
     public CmdException(int code, String msg, Throwable cause) {
         super(msg, cause);
 
-        if(cause != null) {
-            if(cause.getCause() != null) {
+        if (cause != null) {
+            if (cause.getCause() != null) {
                 msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
             }
-            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+            msg += " StackTrace:" + ExceptionUtils.populateExecption(cause, 500);
         }
         this.result = new Result(code, msg);
     }
 
     /**
      * 鏋勯�犳柟娉�
-     * @param code	杩斿洖鐮�
-     * @param cause	寮傚父鍫嗘爤
+     *
+     * @param code  杩斿洖鐮�
+     * @param cause 寮傚父鍫嗘爤
      */
     public CmdException(int code, Throwable cause) {
         super(cause);
         String msg = "";
 
-        if(cause != null) {
-            if(cause.getCause() != null) {
+        if (cause != null) {
+            if (cause.getCause() != null) {
                 msg += " cause:" + ExceptionUtils.populateExecption(cause.getCause(), 500);
             }
-            msg += " StackTrace:"+ExceptionUtils.populateExecption(cause, 500);
+            msg += " StackTrace:" + ExceptionUtils.populateExecption(cause, 500);
         }
         this.result = new Result(code, msg);
     }
 
     /**
-     *
      * TODO 绠�鍗曟弿杩拌鏂规硶鐨勫疄鐜板姛鑳斤紙鍙�夛級.
+     *
      * @see Throwable#getCause()
      */
     public synchronized Throwable getCause() {
-        return (cause==this ? super.getCause() : cause);
+        return (cause == this ? super.getCause() : cause);
     }
 
 
     /**
      * 杩斿洖寮傚父娑堟伅
+     *
      * @return 寮傚父娑堟伅
      */
     @Override
@@ -121,6 +140,7 @@
 
     /**
      * 寮傚父
+     *
      * @return
      */
     public String toJsonString() {
@@ -130,10 +150,11 @@
         if (getResult() != null)
             exceptionJsonObj.putAll(JSONObject.parseObject(result.toString()));
 
-        exceptionJsonObj.put("exceptionTrace",getMessage());
+        exceptionJsonObj.put("exceptionTrace", getMessage());
 
         return exceptionJsonObj.toString();
     }
+
     @Override
     public void printStackTrace(PrintStream ps) {
         ps.print("<exception>");
@@ -176,7 +197,8 @@
 
     /**
      * 杩斿洖寮傚父鍊�
-     * @return	寮傚父鍊煎璞�
+     *
+     * @return 寮傚父鍊煎璞�
      */
     public Result getResult() {
         return result;

--
Gitblit v1.8.0