From 59bf44a943e2536ce3512b635ba960f6a22f4d1a Mon Sep 17 00:00:00 2001 From: David Conner Date: Tue, 21 May 2024 13:49:27 -0400 Subject: [PATCH] Add parsing check to handle exceptions in manifest --- flexbe_core/flexbe_core/behavior_library.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/flexbe_core/flexbe_core/behavior_library.py b/flexbe_core/flexbe_core/behavior_library.py index 3ef3a54..963ea69 100644 --- a/flexbe_core/flexbe_core/behavior_library.py +++ b/flexbe_core/flexbe_core/behavior_library.py @@ -87,7 +87,13 @@ def _add_behavior_manifests(self, path, pkg=None): if os.path.isdir(entry_path): self._add_behavior_manifests(entry_path, pkg) elif entry.endswith(".xml") and not entry.startswith("#"): - mrt = ET.parse(entry_path).getroot() + try: + mrt = ET.parse(entry_path).getroot() + except ET.ParseError as exc: + Logger.logerr(f"XML parsing error while loading behavior manifest\n for '{entry_path}'\n" + f" {exc}\n skipping loading of '{entry}' ...") + continue + # structure sanity check if (mrt.tag != "behavior" or len(mrt.findall(".//executable")) == 0