Commit 0362068e authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

[lib] Try to display clearer error and better error handling after a fail...

[lib] Try to display clearer error and better error handling after a fail while reading an xml file model
parent db95cab8
......@@ -52,13 +52,17 @@ Classes::
from __future__ import unicode_literals
from __future__ import print_function
from cadbiom.models.guard_transitions.chart_model import ChartModel
from xml.sax import make_parser
from xml.sax import parseString
from xml.sax.handler import ContentHandler
from lxml import etree
from lxml import objectify
from cadbiom.models.guard_transitions.chart_model import ChartModel
import cadbiom.commons as cm
LOGGER = cm.logger()
class XmlVisitor:
"""Visitor used to generate xml cadbiom code when the model is exported."""
......@@ -482,13 +486,13 @@ class MakeModelFromXmlFile:
try:
self.parser.parse(xml_file)
# The model is currently not modified in comparison to the file
self.handler.model.modified = False
except Exception:
print("ERROR while xml parsing")
LOGGER.error("Error while reading the XML file <%s>", xml_file)
raise
# The model is currently not modified in comparison to the file
self.handler.model.modified = False
@property
def model(self):
"""Return the model generated from the XML file
......@@ -509,12 +513,12 @@ class MakeModelFromXmlString:
try:
parseString(xml_string, self.handler)
except Exception as exc:
print("ERROR while xml parsing")
print(exc)
# The model is currently not modified in comparison to the file
self.handler.model.modified = False
# The model is currently not modified in comparison to the file
self.handler.model.modified = False
except Exception:
LOGGER.error("Error while reading the XML string")
raise
@property
def model(self):
......
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