commit bc72238a3096320a416e7e4e86db8fe78c63aa81 Author: Radek Pazdera rpazdera@redhat.com Date: Fri Mar 8 11:07:18 2013 +0100
NetTestParse: Fix handler exceptions
The parser wraps exceptions that go through his handler hooks to his own exception class called XmlProcessingError to add information about at which line of the XML file the problem happened.
Doing this however results in discarding the original traceback, which is replaced by different one that leads to the try/catch block. This is not helpful at all. It actually makes debugging extremelly irritating.
This patch changes this behaviour so the parser only logs an error with the line information and it re-raises the original exeption with the original traceback.
Signed-off-by: Radek Pazdera rpazdera@redhat.com
lnst/Controller/NetTestParse.py | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) --- diff --git a/lnst/Controller/NetTestParse.py b/lnst/Controller/NetTestParse.py index 257fe77..430c033 100644 --- a/lnst/Controller/NetTestParse.py +++ b/lnst/Controller/NetTestParse.py @@ -36,10 +36,7 @@ class NetTestParse(RecipeParser): first_pass = FirstPass(self) first_pass.parse(xml_dom)
- try: - self._trigger_event("provisioning_requirements_ready", {}) - except Exception as exc: - raise XmlProcessingError(str(exc), xml_dom) + self._trigger_event("provisioning_requirements_ready", {})
second_pass = SecondPass(self) second_pass.parse(xml_dom) @@ -175,7 +172,8 @@ class MachineParse(RecipeParser): try: self._trigger_event("machine_ready", {"machine_id": self._id}) except Exception as exc: - raise XmlProcessingError(str(exc), node) + logging.error(XmlProcessingError(str(exc), xml_dom)) + raise
class ParamsParse(RecipeParser): _params = None @@ -332,7 +330,8 @@ class SlaveMachineParse(RecipeParser): self._trigger_event("netdevice_ready", {"machine_id": self._machine_id, "dev_id": phys_id}) except Exception as exc: - raise XmlProcessingError(str(exc), node) + logging.error(XmlProcessingError(str(exc), xml_dom)) + raise
class NetConfigParse(RecipeParser): _machine_id = None @@ -388,7 +387,8 @@ class NetConfigParse(RecipeParser): except Exception as exc: msg = "Unable to configure interface %s on machine %s [%s]." % \ (dev_id, self._machine_id, str(exc)) - raise XmlProcessingError(msg, node) + logging.error(XmlProcessingError(str(msg), xml_dom)) + raise
def _process_phys_id_attr(self, node, dev): netconfig = self._netconfig
lnst-developers@lists.fedorahosted.org