improved logging when no exception data is found 38/90538/2
authorBenjamin, Max <max.benjamin@att.com>
Wed, 26 Jun 2019 15:35:00 +0000 (11:35 -0400)
committerMax Benjamin <max.benjamin@att.com>
Thu, 27 Jun 2019 16:09:34 +0000 (16:09 +0000)
improved logging when no exception data is found

Change-Id: I4f6298652ad474119cd1ebc58a927d532ea3e6be
Issue-ID: SO-2068
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBFailure.java

index 35ceef0..4d2f9fd 100644 (file)
@@ -125,7 +125,7 @@ public class WorkflowActionBBFailure {
     }
 
     private Optional<String> retrieveErrorMessage(DelegateExecution execution) {
-        String errorMsg = "";
+        String errorMsg = null;
         try {
             WorkflowException exception = (WorkflowException) execution.getVariable("WorkflowException");
             if (exception != null && (exception.getErrorMessage() != null || !exception.getErrorMessage().equals(""))) {
@@ -134,6 +134,10 @@ public class WorkflowActionBBFailure {
             if (errorMsg == null || errorMsg.equals("")) {
                 errorMsg = (String) execution.getVariable("WorkflowExceptionErrorMessage");
             }
+            if (errorMsg == null) {
+                throw new IllegalStateException(
+                        "could not find WorkflowException or WorkflowExceptionErrorMessage in execution");
+            }
             return Optional.of(errorMsg);
         } catch (Exception ex) {
             logger.error("Failed to extract workflow exception from execution.", ex);