improves exception output

This commit is contained in:
Martinez 2017-01-19 11:36:22 +01:00
parent 2a2a26977a
commit d2c41b6670

View file

@ -741,24 +741,27 @@ class Main:
# if there's a "self" in locals, we can get a hold of the method using getattr
if "self" in frame.f_locals:
method = getattr(frame.f_locals["self"], method_name)
method_display_name = "<c>%s<.>.<y>%s<.>" %(method.__self__.__class__.__name__, method_name)
method_display_name = " <c>%s<.>.<y>%s<.>" %(method.__self__.__class__.__name__, method_name)
method_type = "method"
# if it's a global function, it's likely going to be here
elif method_name in frame.f_globals:
method = frame.f_globals[method_name]
method_display_name = "<y>%s<.>" %(method_name)
method_display_name = " <y>%s<.>" %(method_name)
method_type = "function"
# otherwise give up
else:
method = None
method_display_name = "<y>%s<.>" %(method_name)
method_display_name = ""
if method_name == "<module>":
method_type = "module"
elif method_name == "<genexpr>":
method_type = "a generator expression"
else:
method_type = "<r>unknown callable<.>"
method_display_name = " <y>%s<.>" %(method_name)
# use a docstring-provided action description if available
if method and method.__doc__ and "@while" in method.__doc__:
@ -766,7 +769,7 @@ class Main:
else:
action = ""
tb_lines.append("%sin %s <y>%s<.> at %s:%d," %(action, method_type, method_display_name, frame.f_code.co_filename, frame.f_lineno))
tb_lines.append("%sin %s%s at %s:%d," %(action, method_type, method_display_name, frame.f_code.co_filename, frame.f_lineno))
if hasattr(exception, "description"):
reason = ": <R>%s<.>" %(exception.description)