diff options
Diffstat (limited to 'framework/src/main/java')
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/conf/OnapCommandConstants.java | 4 | ||||
-rw-r--r-- | framework/src/main/java/org/onap/cli/fw/error/OnapCommandException.java | 7 |
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); |