small refactor
This commit is contained in:
12
inspector.py
12
inspector.py
@ -148,10 +148,7 @@ def format_value(obj): #TODO: make magic numbers configurable
|
|||||||
try:
|
try:
|
||||||
res = str(obj)
|
res = str(obj)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
tn = typename(e)
|
res = printable_error(e)
|
||||||
res = f"caused a {tn}"
|
|
||||||
if str(e): # e has a message
|
|
||||||
res += f": {e}"
|
|
||||||
# try if separate lines can be used to shorten
|
# try if separate lines can be used to shorten
|
||||||
splitted = res.split("\n")
|
splitted = res.split("\n")
|
||||||
if len(splitted) > 4:
|
if len(splitted) > 4:
|
||||||
@ -177,6 +174,13 @@ def format_bkg_color(obj):
|
|||||||
def typename(obj):
|
def typename(obj):
|
||||||
return type(obj).__name__
|
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()
|
inspector = VariableInspector()
|
||||||
|
Reference in New Issue
Block a user