diff --git a/pyQuARC/main.py b/pyQuARC/main.py index 8982d41b..0159b67a 100644 --- a/pyQuARC/main.py +++ b/pyQuARC/main.py @@ -237,22 +237,25 @@ def _error_message(messages): @staticmethod def _format_cmr_error(cmr_validation): - if not cmr_validation.get("errors"): + cmr_errors = cmr_validation.get("errors") + if not cmr_errors: return None error_msg_dict = {} error_msg = "" - if errors := cmr_validation.get("errors"): - for error in errors: - if type(error) is dict and error.get("path"): - if error["path"][0] not in error_msg_dict: - error_msg_dict[error["path"][0]] = [] - error_msg_dict[error["path"][0]].append(error['errors']) - else: - error_msg_dict["Misc"] = [error] + for error in cmr_errors: + if type(error) is dict and error.get("path"): + if error["path"][0] not in error_msg_dict: + error_msg_dict[error["path"][0]] = [] + error_msg_dict[error["path"][0]].append(error['errors']) + else: + error_msg_dict["Misc"] = [error] for path, errors in error_msg_dict.items(): error_msg += f"\n\t>> {path}: {END}\n" for error in errors: - error_msg += f"\t\t{COLOR['error']}Error:{END} {str(error)}\n" + error_str = str(error) + if isinstance(error, list): + error_str = ", ".join(error) + error_msg += f"\t\t{COLOR['error']}Error:{END} {error_str}\n" return error_msg def display_results(self):