provide more info in error screen, and link to support site

This commit is contained in:
Damien Elmes 2017-09-06 16:40:35 +10:00
parent e518619ed3
commit 2e7da0f3c6
2 changed files with 40 additions and 12 deletions

View File

@ -97,28 +97,56 @@ Possible causes:
It's a good idea to run Tools>Check Database to ensure your collection \ It's a good idea to run Tools>Check Database to ensure your collection \
is not corrupt. is not corrupt.
""")) """))
stdText = _("""\ stdText = _("""\
An error occurred. It may have been caused by a harmless bug, <br> <h1>Error</h1>
or your deck may have a problem.
<p>To confirm it's not a problem with your deck, please run <p>An error occurred. Please use <b>Tools &gt; Check Database</b> to see if \
<b>Tools &gt; Check Database</b>. that fixes the problem.</p>
<p>If that doesn't fix the problem, please copy the following<br>
into a bug report:""") <p>If problems persist, please report the problem on our \
<a href="https://help.ankiweb.net">support site</a>. Please copy and paste \
the information below into your report.</p>""")
pluginText = _("""\ pluginText = _("""\
<h1>Error</h1>
<p>An error occurred. Please start Anki while holding down the shift \ <p>An error occurred. Please start Anki while holding down the shift \
key, which will temporarily disable the add-ons you have installed.</p> key, which will temporarily disable the add-ons you have installed.</p>
<p>If the problem occurs even with add-ons disabled, please report the \
issue on our support site.</p>
<p>If the issue only occurs when add-ons are enabled, please use the \ <p>If the issue only occurs when add-ons are enabled, please use the \
Tools&gt;Add-ons menu item to disable one add-on and restart Anki, \ Tools&gt;Add-ons menu item to disable some add-ons and restart Anki, \
repeating until you discover the add-on that is causing the problem.</p> repeating until you discover the add-on that is causing the problem.</p>
<p>When you've discovered the add-on that is causing the problem, please \
report the issue on the <a href="https://help.ankiweb.net/discussions/add-ons/">\
add-ons section</a> of our support site.
<p>Debug info:</p>
""") """)
if self.mw.addonManager.dirty: if self.mw.addonManager.dirty:
txt = pluginText txt = pluginText
else: else:
txt = stdText txt = stdText
# show dialog # show dialog
error = self._supportText() + "\n" + error
txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>" txt = txt + "<div style='white-space: pre-wrap'>" + error + "</div>"
showText(txt, type="html") showText(txt, type="html")
def _supportText(self):
import platform
from aqt import appVersion
if isWin:
platname = "Windows " + platform.win32_ver()[0]
elif isMac:
platname = "Mac " + platform.mac_ver()[0]
else:
platname = "Linux"
return f"""\
Anki {appVersion} Python {platform.python_version()} Qt {QT_VERSION_STR} PyQt {PYQT_VERSION_STR}
Platform: {platname}
Flags: frz={getattr(sys, "frozen", False)} ao={self.mw.addonManager.dirty}
"""

View File

@ -66,8 +66,8 @@ def showText(txt, parent=None, type="text", run=True, geomKey=None, \
diag.setWindowTitle(title) diag.setWindowTitle(title)
layout = QVBoxLayout(diag) layout = QVBoxLayout(diag)
diag.setLayout(layout) diag.setLayout(layout)
text = QTextEdit() text = QTextBrowser()
text.setReadOnly(True) text.setOpenExternalLinks(True)
if type == "text": if type == "text":
text.setPlainText(txt) text.setPlainText(txt)
else: else: