From 1081d4a60c812810510b6e1c2ce6d5a2e2f0807b Mon Sep 17 00:00:00 2001 From: Philip Hackstock <20710924+phackstock@users.noreply.github.com> Date: Mon, 22 Jan 2024 17:56:27 +0100 Subject: [PATCH] Improve ErrorCollector formatting --- nomenclature/error.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nomenclature/error.py b/nomenclature/error.py index 2bf2c6c0..39296ce2 100644 --- a/nomenclature/error.py +++ b/nomenclature/error.py @@ -1,3 +1,4 @@ +import textwrap from collections import namedtuple pydantic_custom_error_config = { @@ -55,8 +56,12 @@ def append(self, error: Exception) -> None: def __repr__(self) -> str: error = "error" if len(self.errors) == 1 else "errors" - return f"Collected {len(self.errors)} {error}:\n" + "\n\t".join( - str(error) for error in self.errors + error_list_str = "\n".join( + f"{i+1}. {error}" for i, error in enumerate(self.errors) + ) + + return f"Collected {len(self.errors)} {error}:\n" + textwrap.indent( + error_list_str, prefix=" " ) def __bool__(self) -> bool: