error messages: print cause tree as part of error

This commit is contained in:
Gregory Becker 2022-12-13 11:01:29 -08:00
parent c1d6d93388
commit f4402c1cde

View File

@ -626,9 +626,9 @@ def _get_cause_tree(self, cause, conditions, condition_causes, literals, indent=
)
]
def get_cause_tree(self, cause):
conditions = dict(extract_args(self.model, "condition"))
condition_causes = list(extract_args(self.model, "condition_cause"))
def get_cause_tree(self, result, best_model, cause):
conditions = dict(extract_args(best_model, "condition"))
condition_causes = list(extract_args(best_model, "condition_cause"))
return self._get_cause_tree(cause, conditions, condition_causes, [])
def handle_error(self, msg, *args):
@ -650,10 +650,6 @@ def handle_error(self, msg, *args):
msg = msg.format(*msg_args)
for cause in set(cause_args):
for c in self.get_cause_tree(cause):
msg += f"\n{c}"
# For variant formatting, we sometimes have to construct specs
# to format values properly. Find/replace all occurances of
# Spec(...) with the string representation of the spec mentioned
@ -661,6 +657,10 @@ def handle_error(self, msg, *args):
for spec_str in specs_to_construct:
msg = msg.replace("Spec(%s)" % spec_str, str(spack.spec.Spec(spec_str)))
for cause in set(cause_args):
for c in self.get_cause_tree(cause):
msg += f"\n{c}"
return msg
def message(self, errors) -> str: