Different exception is raised when an included file didn't exist. In that case, controller would crash with an exception.
This commit adds an additional branch to handle generic exceptions too.
Issue #46
Signed-off-by: Radek Pazdera rpazdera@redhat.com --- lnst/Common/XmlParser.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lnst/Common/XmlParser.py b/lnst/Common/XmlParser.py index c60b410..4cde0b4 100644 --- a/lnst/Common/XmlParser.py +++ b/lnst/Common/XmlParser.py @@ -81,7 +81,7 @@ class XmlParser(object): def _parse(self, path): try: doc = etree.parse(path) - except Exception as err: + except etree.LxmlError as err: # A workaround for cases when lxml (quite strangely) # sets the filename to <string>. if err.error_log[0].filename == "<string>": @@ -94,6 +94,13 @@ class XmlParser(object): exc = XmlProcessingError(err.error_log[0].message) exc.set_loc(loc) raise exc + except Exception as err: + loc = {"file": os.path.basename(self._path), + "line": None, + "col": None} + exc = XmlProcessingError(str(err)) + exc.set_loc(loc) + raise exc
return doc
lnst-developers@lists.fedorahosted.org