mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-14 05:21:41 +08:00
添加全局异常错误提示
This commit is contained in:
parent
f77a24ce4d
commit
4d9275d667
@ -266,7 +266,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
|
|||||||
self.outputThread.start()
|
self.outputThread.start()
|
||||||
elif self.sender() == self.action_batch_export:
|
elif self.sender() == self.action_batch_export:
|
||||||
dialog = ExportDialog(None, title='批量导出聊天记录', parent=self)
|
dialog = ExportDialog(None, title='批量导出聊天记录', parent=self)
|
||||||
result = dialog.exec_() # 使用exec_()获取用户的操作结果
|
result = dialog.exec_() # 使用exec_()获取用户的操作结果
|
||||||
|
|
||||||
def message(self, msg):
|
def message(self, msg):
|
||||||
self.stopBusy()
|
self.stopBusy()
|
||||||
|
@ -231,10 +231,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="section" style="text-align: center;display:flex;justify-content: center;align-items: center;">
|
<div class="section" style="text-align: center;display:flex;justify-content: center;align-items: center;">
|
||||||
<h1 style="text-align: center;">敬请期待</h1>
|
<h1 style="text-align: center;">敬请期待</h1>
|
||||||
|
<a href="https://memotrace.lc044.love/" target="_blank">点击生成我的年度聊天报告</a>
|
||||||
<h1>分享此页面</h1>
|
<h1>分享此页面</h1>
|
||||||
<button onclick="confirmUpload()">上传并显示二维码</button>
|
<button onclick="confirmUpload()">上传并显示二维码</button>
|
||||||
|
|
||||||
<div id="qrcode"></div>
|
<div id="qrcode"></div>
|
||||||
|
<a href="https://memotrace.lc044.love/" target="_blank">https://memotrace.lc044.love/</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- Add more sections as needed -->
|
<!-- Add more sections as needed -->
|
||||||
</div>
|
</div>
|
||||||
|
24
main.py
24
main.py
@ -3,6 +3,8 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
from app.ui.Icon import Icon
|
||||||
|
|
||||||
widget = None
|
widget = None
|
||||||
|
|
||||||
|
|
||||||
@ -12,9 +14,25 @@ def excepthook(exc_type, exc_value, traceback_):
|
|||||||
# 在这里处理全局异常
|
# 在这里处理全局异常
|
||||||
|
|
||||||
error_message = ''.join(traceback.format_exception(exc_type, exc_value, traceback_))
|
error_message = ''.join(traceback.format_exception(exc_type, exc_value, traceback_))
|
||||||
msg = f"Exception Type: {exc_type.__name__}\nException Value: {exc_value}\ndetails: {error_message}"
|
txt = '您可添加QQ群发送log文件以便解决该问题'
|
||||||
|
msg = f"Exception Type: {exc_type.__name__}\nException Value: {exc_value}\ndetails: {error_message}\n\n{txt}"
|
||||||
logger.error(f'程序发生了错误:\n\n{msg}')
|
logger.error(f'程序发生了错误:\n\n{msg}')
|
||||||
QMessageBox.critical(None, "Unhandled Exception", msg, QMessageBox.Ok)
|
# 创建一个 QMessageBox 对象
|
||||||
|
error_box = QMessageBox()
|
||||||
|
|
||||||
|
# 设置对话框的标题
|
||||||
|
error_box.setWindowTitle("未知错误")
|
||||||
|
pixmap = QPixmap(Icon.logo_ico_path)
|
||||||
|
icon = QIcon(pixmap)
|
||||||
|
error_box.setWindowIcon(icon)
|
||||||
|
# 设置对话框的文本消息
|
||||||
|
error_box.setText(msg)
|
||||||
|
# 设置对话框的图标,使用 QMessageBox.Critical 作为图标类型
|
||||||
|
error_box.setIcon(QMessageBox.Critical)
|
||||||
|
# 添加一个“确定”按钮
|
||||||
|
error_box.addButton(QMessageBox.Ok)
|
||||||
|
# 显示对话框
|
||||||
|
error_box.exec_()
|
||||||
|
|
||||||
# 调用原始的 excepthook,以便程序正常退出
|
# 调用原始的 excepthook,以便程序正常退出
|
||||||
sys.__excepthook__(exc_type, exc_value, traceback_)
|
sys.__excepthook__(exc_type, exc_value, traceback_)
|
||||||
@ -22,7 +40,7 @@ def excepthook(exc_type, exc_value, traceback_):
|
|||||||
|
|
||||||
# 设置 excepthook
|
# 设置 excepthook
|
||||||
sys.excepthook = excepthook
|
sys.excepthook = excepthook
|
||||||
from PyQt5.QtGui import QFont
|
from PyQt5.QtGui import QFont, QPixmap, QIcon
|
||||||
from PyQt5.QtWidgets import *
|
from PyQt5.QtWidgets import *
|
||||||
from PyQt5.QtCore import Qt
|
from PyQt5.QtCore import Qt
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user