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
LOGGER = cm.logger()
class ErrorRep(object):
class ErrorReporter(object):
"""Cf class CompilReporter(object):
gt_gui/utils/reporter.py
"""
......@@ -68,11 +68,11 @@ class ErrorRep(object):
def display(self, mess):
self.error = True
LOGGER.error(">> Context: %s; %s", self.context, mess)
LOGGER.error("solution_search:: Context: %s; %s", self.context, mess)
exit()
def display_info(self, mess):
LOGGER.error("-- Context: %s; %s", self.context, mess)
LOGGER.error("solution_search:: Context: %s; %s", self.context, mess)
exit()
def set_context(self, cont):
......@@ -206,7 +206,7 @@ def search_entry_point(
:type limit: <int>
"""
# Build MCLA with Error Reporter
mcla = MCLAnalyser(ErrorRep())
mcla = MCLAnalyser(ErrorReporter())
# Load model file
detect_model_type(mcla, model_file)(model_file)
......@@ -484,7 +484,7 @@ def detect_model_type(mclanalyser, filepath):
# start_prop = mac_p
#
# # BUILD MCLA
# error_reporter = ErrorRep()
# error_reporter = ErrorReporter()
# mcla = MCLAnalyser(error_reporter)
# mcla.build_from_chart_file(model_file)
#
......
......@@ -53,8 +53,10 @@ LOGGER = cm.logger()
class Reporter(object):
"""Error reporter.
.. note:: Link the lexer to the model allows to avoid error in Reporter
like: "-> dec -> Undeclared event or state"
.. note:: Link the lexer to the model allows to avoid some errors in Reporter.
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.
See parse_condition()
"""
......@@ -63,11 +65,14 @@ class Reporter(object):
self.error = False
self.mess = ""
def display(self, err):
def display(self, error_msg):
"""Display the error in the logger"""
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):
......
......@@ -55,11 +55,11 @@ class ErrorRep(object):
def display(self, mess):
self.error = True
LOGGER.error(">> Context: {}; {}".format(self.context, mess))
LOGGER.error("add_start_nodes:: Context: {}; {}".format(self.context, mess))
exit()
def display_info(self, mess):
LOGGER.error("-- Context: {}; {}".format(self.context, mess))
LOGGER.error("add_start_nodes:: Context: {}; {}".format(self.context, mess))
exit()
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