From 0e80c66c7126e9d420c71f4749415beefcddd5b0 Mon Sep 17 00:00:00 2001 From: havocrao Date: Wed, 20 Aug 2025 11:12:13 +0800 Subject: [PATCH] fix: up --- main.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 25abf58..628c6f6 100755 --- a/main.py +++ b/main.py @@ -149,7 +149,16 @@ def main(): except KeyboardInterrupt: print("\n程序被用户中断") except Exception as e: - print(f"发生错误: {e}") + import traceback + import sys + exc_type, exc_value, exc_tb = sys.exc_info() + tb = traceback.extract_tb(exc_tb) + if tb: + last_call = tb[-1] + print(f"发生错误: {e}(文件: {last_call.filename}, 行号: {last_call.lineno}, 函数: {last_call.name})") + else: + print(f"发生错误: {e}") + traceback.print_exc() finally: print("正在清理资源...") Ctrl.quit()