Commit 48cf40da authored by Jerome Mariette's avatar Jerome Mariette
Browse files

better handle of errors

parent bc5edc7d
......@@ -136,7 +136,7 @@ class Workflow(threading.Thread):
return cmpt_object
else:
sys.exit(component_name + " component cannot be loaded, available components are: " + ", ".join(self.comp_pckg.keys()))
raise ImportError(component_name + " component cannot be loaded, available components are: {0}".format(", ".join(self.comp_pckg.keys())))
def pre_process(self):
pass
......@@ -177,12 +177,16 @@ class Workflow(threading.Thread):
self._serialize()
# if not done yet, init the component nameids list before to run
if not self.component_nameids_is_init:
try: self.process()
except SystemExit, e: print e
try:
self.process()
except SystemExit, e:
raise RuntimeError('An error occurred when executing workflow: {0}'.format(e))
self.component_nameids_is_init = True
self._serialize()
try: self.process()
except SystemExit, e: print e
try:
self.process()
except SystemExit, e:
raise RuntimeError('An error occurred when executing workflow: {0}'.format(e))
if len(self.components) > 0:
self._execute_weaver()
self._serialize()
......@@ -339,9 +343,9 @@ class Workflow(threading.Thread):
# create the DAG
nest.compile()
except Exception as e:
sys.exit('Error compiling script: {0}'.format(e))
self.status = self.STATUS_FAILED
self._serialize()
raise SyntaxError('An error occurred when compiling script: {0}'.format(e))
self.components = []
# Once a weaver script is compiled, serialize the workflow
self._serialize()
......@@ -351,7 +355,7 @@ class Workflow(threading.Thread):
self.status = self.STATUS_FAILED
self.end_time = time.time()
self._serialize()
sys.exit()
raise RuntimeError('An error occurred when executing DAG from directory {0}'.format(current_working_directory))
def _get_current_make(self):
current_component, make_directory, new_make = [], None, False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment