Commit 1a277f96 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] Improve error handling during the parsing of conditions/events

parent 492edf96
...@@ -57,7 +57,7 @@ import cadbiom.commons as cm ...@@ -57,7 +57,7 @@ import cadbiom.commons as cm
LOGGER = cm.logger() LOGGER = cm.logger()
class ErrorRep(object): class ErrorReporter(object):
"""Cf class CompilReporter(object): """Cf class CompilReporter(object):
gt_gui/utils/reporter.py gt_gui/utils/reporter.py
""" """
...@@ -68,11 +68,11 @@ class ErrorRep(object): ...@@ -68,11 +68,11 @@ class ErrorRep(object):
def display(self, mess): def display(self, mess):
self.error = True self.error = True
LOGGER.error(">> Context: %s; %s", self.context, mess) LOGGER.error("solution_search:: Context: %s; %s", self.context, mess)
exit() exit()
def display_info(self, mess): def display_info(self, mess):
LOGGER.error("-- Context: %s; %s", self.context, mess) LOGGER.error("solution_search:: Context: %s; %s", self.context, mess)
exit() exit()
def set_context(self, cont): def set_context(self, cont):
...@@ -206,7 +206,7 @@ def search_entry_point( ...@@ -206,7 +206,7 @@ def search_entry_point(
:type limit: <int> :type limit: <int>
""" """
# Build MCLA with Error Reporter # Build MCLA with Error Reporter
mcla = MCLAnalyser(ErrorRep()) mcla = MCLAnalyser(ErrorReporter())
# Load model file # Load model file
detect_model_type(mcla, model_file)(model_file) detect_model_type(mcla, model_file)(model_file)
...@@ -484,7 +484,7 @@ def detect_model_type(mclanalyser, filepath): ...@@ -484,7 +484,7 @@ def detect_model_type(mclanalyser, filepath):
# start_prop = mac_p # start_prop = mac_p
# #
# # BUILD MCLA # # BUILD MCLA
# error_reporter = ErrorRep() # error_reporter = ErrorReporter()
# mcla = MCLAnalyser(error_reporter) # mcla = MCLAnalyser(error_reporter)
# mcla.build_from_chart_file(model_file) # mcla.build_from_chart_file(model_file)
# #
......
...@@ -53,8 +53,10 @@ LOGGER = cm.logger() ...@@ -53,8 +53,10 @@ LOGGER = cm.logger()
class Reporter(object): class Reporter(object):
"""Error reporter. """Error reporter.
.. note:: Link the lexer to the model allows to avoid error in Reporter .. note:: Link the lexer to the model allows to avoid some errors in Reporter.
like: "-> dec -> Undeclared event or state" We mask error like: "-> dec -> Undeclared event or state".
This error is generated for every place in a condition/event and should
only mean that an item has never been met.
In practice this is time consuming and useless for what we want to do. In practice this is time consuming and useless for what we want to do.
See parse_condition() See parse_condition()
""" """
...@@ -63,11 +65,14 @@ class Reporter(object): ...@@ -63,11 +65,14 @@ class Reporter(object):
self.error = False self.error = False
self.mess = "" self.mess = ""
def display(self, err): def display(self, error_msg):
"""Display the error in the logger""" """Display the error in the logger"""
self.error = True self.error = True
if "Undeclared event or state" not in err:
LOGGER.error("\t" + self.mess + " -> " + err) if "Undeclared event or state" in error_msg:
return
LOGGER.error("Event or condition parser:: %s", error_msg)
def get_transitions_from_model_file(model_file): def get_transitions_from_model_file(model_file):
......
...@@ -55,11 +55,11 @@ class ErrorRep(object): ...@@ -55,11 +55,11 @@ class ErrorRep(object):
def display(self, mess): def display(self, mess):
self.error = True self.error = True
LOGGER.error(">> Context: {}; {}".format(self.context, mess)) LOGGER.error("add_start_nodes:: Context: {}; {}".format(self.context, mess))
exit() exit()
def display_info(self, mess): def display_info(self, mess):
LOGGER.error("-- Context: {}; {}".format(self.context, mess)) LOGGER.error("add_start_nodes:: Context: {}; {}".format(self.context, mess))
exit() exit()
def set_context(self, cont): def set_context(self, cont):
......
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