Skip to content

Commit f8ed6c5

Browse files
authored
fix(error): improve representation (#38)
1 parent 95d821a commit f8ed6c5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/core/ydata/core/error/fabric_error.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def _camelcased(value: str) -> str:
88
return capitalized[0].lower() + capitalized[1:]
99

1010

11-
# pylint: disable=too-many-arguments
11+
# pylint: disable=too-many-arguments, import-outside-toplevel
1212
class FabricError(Exception):
1313
context: dict[str, str] | None
1414
description: str
@@ -43,14 +43,16 @@ def __iter__(self):
4343
"return_value": self.return_value
4444
}.items()
4545

46-
def __str__(self) -> str:
47-
return f'''
48-
{self.__class__.__name__}(name={self.name}, context={self.context}, description={self.description}, \
49-
http_code={self.http_code}, return_value={self.return_value})
50-
'''
51-
5246
def __repr__(self) -> str:
53-
return self.__str__()
47+
from pprint import pformat
48+
return f"{self.__class__.__name__}(\n{pformat(dict(self), width=120, sort_dicts=False)}\n)"
49+
50+
def __str__(self) -> str:
51+
from pprint import pformat
52+
string = f"{self.name} - {self.description}"
53+
if self.context:
54+
string += f"\ncontext: {pformat(self.context, width=160, sort_dicts=False)}"
55+
return string
5456

5557
def __sizeof__(self) -> int:
5658
context_size = getsizeof(self.context) if self.context else 0

0 commit comments

Comments
 (0)