From bfa9f535aadb7f01dc206efd463fcc37f25abc95 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 11 Jul 2021 01:59:07 +0200 Subject: [PATCH] more context in exceptions --- copyparty/util.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/copyparty/util.py b/copyparty/util.py index 8b6b2b7c..649edf08 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -284,13 +284,11 @@ def alltrace(): def min_ex(): et, ev, tb = sys.exc_info() - tb = traceback.extract_tb(tb, 2) - ex = [ - "{} @ {} <{}>: {}".format(fp.split(os.sep)[-1], ln, fun, txt) - for fp, ln, fun, txt in tb - ] - ex.append("{}: {}".format(et.__name__, ev)) - return "\n".join(ex) + tb = traceback.extract_tb(tb) + fmt = "{} @ {} <{}>: {}" + ex = [fmt.format(fp.split(os.sep)[-1], ln, fun, txt) for fp, ln, fun, txt in tb] + ex.append("[{}] {}".format(et.__name__, ev)) + return "\n".join(ex[-8:]) @contextlib.contextmanager