summaryrefslogtreecommitdiffstats
path: root/tools/model-generator
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-14 16:45:06 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-14 16:45:17 +0100
commita65e4772f4557a109917532b2d9c49680ce3bb15 (patch)
tree1669786f0b3ce82e005debc53218825d537841c8 /tools/model-generator
parent6d72a4a1e5d8678ecd8b093480ea9543089015b0 (diff)
Fix exception not logged or rethrown
Eclipse sonarlint does not check for exception dropping by default, it must be configured. This commit addresses exception dropping in apex. Change-Id: I406838990b3424c2912124b25d7326502cacc96c Issue-ID: POLICY-1034 Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'tools/model-generator')
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java8
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java8
2 files changed, 14 insertions, 2 deletions
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java
index 236750310..b6c6b774c 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java
@@ -26,6 +26,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
import org.onap.policy.apex.tools.common.OutputFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Process an Apex Policy Model file to generate the CLI commands to generate an equivalent Apex Policy Model.
@@ -33,6 +35,8 @@ import org.onap.policy.apex.tools.common.OutputFile;
* @author Sven van der Meer &lt;sven.van.der.meer@ericsson.com&gt;
*/
public final class Application {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/** The name of the application. */
public static final String APP_NAME = "gen-model2cli";
@@ -118,7 +122,9 @@ public final class Application {
final Model2Cli app = new Model2Cli(modelFile, outfile, !cmd.hasOption("sv"), APP_NAME);
app.runApp();
} catch (final ApexException aex) {
- System.err.println(APP_NAME + ": caught APEX exception with message: " + aex.getMessage());
+ String message = APP_NAME + ": caught APEX exception with message: " + aex.getMessage();
+ System.err.println(message);
+ LOGGER.warn(message, aex);
}
}
}
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java
index 2bc70f69e..9735293cf 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java
@@ -25,6 +25,8 @@ import org.apache.commons.cli.HelpFormatter;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Model 2 event generator with main method.
@@ -32,6 +34,8 @@ import org.onap.policy.apex.tools.common.CliParser;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public final class Application {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/** The name of the application. */
public static final String APP_NAME = "gen-model2event";
@@ -105,7 +109,9 @@ public final class Application {
final Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
app.runApp();
} catch (final ApexException aex) {
- System.err.println(APP_NAME + ": caught APEX exception with message: " + aex.getMessage());
+ String message = APP_NAME + ": caught APEX exception with message: " + aex.getMessage();
+ System.err.println(message);
+ LOGGER.warn(message, aex);
}
}
}