small refactor

This commit is contained in:
2021-10-25 12:55:42 +02:00
parent fa944f1964
commit e3246f9bd7

View File

@ -148,10 +148,7 @@ def format_value(obj): #TODO: make magic numbers configurable
try:
res = str(obj)
except Exception as e:
tn = typename(e)
res = f"caused a {tn}"
if str(e): # e has a message
res += f": {e}"
res = printable_error(e)
# try if separate lines can be used to shorten
splitted = res.split("\n")
if len(splitted) > 4:
@ -177,6 +174,13 @@ def format_bkg_color(obj):
def typename(obj):
return type(obj).__name__
def printable_error(exc):
tn = typename(exc)
res = f"caused a {tn}"
if str(exc): # exc has a message
res += f": {exc}"
return res
inspector = VariableInspector()