diff --git a/aqt/errors.py b/aqt/errors.py
index 6b38174cc..699593552 100644
--- a/aqt/errors.py
+++ b/aqt/errors.py
@@ -3,10 +3,12 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import sys, traceback
import html
+import re
from anki.lang import _
from aqt.qt import *
from aqt.utils import showText, showWarning
+from aqt import mw
if not os.environ.get("DEBUG"):
def excepthook(etype,val,tb):
@@ -121,16 +123,29 @@ report the issue on the
add-ons section of our support site.
Debug info:
-""")
+""")
if self.mw.addonManager.dirty:
txt = pluginText
+ error = self._supportText() + self._addonText(error) + "\n" + error
else:
txt = stdText
+ error = self._supportText() + "\n" + error
+
# show dialog
- error = self._supportText() + "\n" + error
-
txt = txt + "" + error + "
"
- showText(txt, type="html")
+ showText(txt, type="html", copyBtn=True)
+
+ def _addonText(self, error):
+ matches = re.findall(r"addons21/(.*?)/", error)
+ if not matches:
+ return ""
+ # reverse to list most likely suspect first, dict to deduplicate:
+ addons = [mw.addonManager.addonName(i) for i in
+ dict.fromkeys(reversed(matches))]
+ txt = _("""Potentially affected add-ons: {}\n""")
+ # highlight importance of first add-on:
+ addons[0] = "{}".format(addons[0])
+ return txt.format(", ".join(addons))
def _supportText(self):
import platform
diff --git a/aqt/utils.py b/aqt/utils.py
index 1221ce8b7..0e6168417 100644
--- a/aqt/utils.py
+++ b/aqt/utils.py
@@ -50,7 +50,7 @@ def showInfo(text, parent=False, help="", type="info", title="Anki"):
return mb.exec_()
def showText(txt, parent=None, type="text", run=True, geomKey=None, \
- minWidth=500, minHeight=400, title="Anki"):
+ minWidth=500, minHeight=400, title="Anki", copyBtn=False):
if not parent:
parent = aqt.mw.app.activeWindow() or aqt.mw
diag = QDialog(parent)
@@ -66,6 +66,12 @@ def showText(txt, parent=None, type="text", run=True, geomKey=None, \
layout.addWidget(text)
box = QDialogButtonBox(QDialogButtonBox.Close)
layout.addWidget(box)
+ if copyBtn:
+ def onCopy():
+ QApplication.clipboard().setText(text.toPlainText())
+ btn = QPushButton(_("Copy to Clipboard"))
+ btn.clicked.connect(onCopy)
+ box.addButton(btn, QDialogButtonBox.ActionRole)
def onReject():
if geomKey:
saveGeom(diag, geomKey)