This commit is contained in:
havocrao 2025-08-20 11:12:13 +08:00
parent 088f5c96c2
commit 0e80c66c71

11
main.py
View File

@ -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()