aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main/java
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-12-26 15:22:27 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-12-26 15:22:27 +0530
commitdf20c73d6c5693ac1cb720b67ad5b1731a8c6104 (patch)
treee8e59ff34a5abf5c19544473008334155f4d73a7 /framework/src/main/java
parent5180adaf7ee371b3387c87499b2bfbbf566e491d (diff)
Add toJsonMessage to Exception class
Issue-ID: CLI-66 Change-Id: Ic4553c28e20cd6db9add438339423dd458ab7d76 Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java4
-rw-r--r--framework/src/main/java/org/onap/cli/fw/error/OnapCommandException.java7
2 files changed, 11 insertions, 0 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
index 3b2188f3..a8fb9d37 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java
@@ -124,6 +124,10 @@ public class OnapCommandConstants {
public static final String BOOLEAN_FALSE = "false";
// Error message
+ public static final String ERROR= "error";
+ public static final String ERROR_CODE= "code";
+ public static final String ERROR_MESSAGE= "message";
+
public static final String SCHEMA_INVALID_DEFAULT_PARAMS_SECTION = "Invalid default_parameter section";
public static final String SCHEMA_FILE_EMPTY = "The schema file cann't be null or empty";
public static final String SCHEMA_FILE_WRONG_EXTN = "Schema file should be '.yaml' extension";
diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandException.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandException.java
index 3fecad02..5dffde5c 100644
--- a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandException.java
+++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandException.java
@@ -16,6 +16,7 @@
package org.onap.cli.fw.error;
+import org.onap.cli.fw.conf.OnapCommandConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -89,6 +90,12 @@ public class OnapCommandException extends Exception {
return message;
}
+ public String toJsonString() {
+ return "{\""+ OnapCommandConstants.ERROR + "\": {\""+
+ OnapCommandConstants.ERROR_CODE + "\": \"" + this.errorCode + "\", \""+
+ OnapCommandConstants.ERROR_MESSAGE + "\": \"" + this.errorMessage + "\"}}";
+ }
+
public OnapCommandException(String errorCode, String errorMessage, Throwable e) {
this(errorCode, errorMessage + ", " + e.getMessage());
LOG.error(this.getMessage(), e);