Explicit error message in command-executor when script is failing 84/109584/2
authorJulien Fontaine <julien.fontaine@bell.ca>
Thu, 25 Jun 2020 21:10:02 +0000 (17:10 -0400)
committerKAPIL SINGAL <ks220y@att.com>
Fri, 26 Jun 2020 04:33:25 +0000 (04:33 +0000)
Changed error message to print the last execution log (if possible) when the executed script fails.

Issue-ID: CCSDK-2481
Signed-off-by: Julien Fontaine <julien.fontaine@bell.ca>
Change-Id: I9df9dfeeaf95d98049c4f80f827deb85a29137da

ms/command-executor/src/main/python/command_executor_handler.py

index 0c476b2..7c9ef84 100644 (file)
@@ -151,7 +151,12 @@ class CommandExecutorHandler():
         if rc == 0:
             return utils.build_ret_data(True, results=result, results_log=results_log)
         else:
-            err_msg = "{} - Something wrong happened during command execution. See execute command logs for more information.".format(self.blueprint_id)
+            err_msg = ""
+            if len(results_log) > 0:
+                # get exception message
+                err_msg = "{} - {}".format(self.blueprint_id, results_log[-1:][0])
+            else:
+                err_msg = "{} - Process exited with return code {}".format(self.blueprint_id, rc)
             return utils.build_ret_data(False, results=result, results_log=results_log, error=err_msg)
 
     def install_packages(self, request, type, f, results):