mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Ensure only the first fatal error is shown
https://forums.ankiweb.net/t/a-fatal-error-occurred-and-anki-must-close-please-report-this-message-on-the-forums/21913
This commit is contained in:
parent
56f806146c
commit
8a62e9c95e
1 changed files with 6 additions and 3 deletions
|
@ -50,6 +50,7 @@ if not os.environ.get("DEBUG"):
|
||||||
class ErrorHandler(QObject):
|
class ErrorHandler(QObject):
|
||||||
"Catch stderr and write into buffer."
|
"Catch stderr and write into buffer."
|
||||||
ivl = 100
|
ivl = 100
|
||||||
|
fatal_error_encountered = False
|
||||||
|
|
||||||
errorTimer = pyqtSignal()
|
errorTimer = pyqtSignal()
|
||||||
|
|
||||||
|
@ -91,6 +92,9 @@ class ErrorHandler(QObject):
|
||||||
return tr.qt_misc_unable_to_access_anki_media_folder()
|
return tr.qt_misc_unable_to_access_anki_media_folder()
|
||||||
|
|
||||||
def onTimeout(self) -> None:
|
def onTimeout(self) -> None:
|
||||||
|
if self.fatal_error_encountered:
|
||||||
|
# suppress follow-up errors caused by the poisoned lock
|
||||||
|
return
|
||||||
error = html.escape(self.pool)
|
error = html.escape(self.pool)
|
||||||
self.pool = ""
|
self.pool = ""
|
||||||
self.mw.progress.clear()
|
self.mw.progress.clear()
|
||||||
|
@ -113,9 +117,8 @@ class ErrorHandler(QObject):
|
||||||
showWarning(markdown(tr.errors_accessing_db()))
|
showWarning(markdown(tr.errors_accessing_db()))
|
||||||
return
|
return
|
||||||
|
|
||||||
must_close = False
|
|
||||||
if "PanicException" in error:
|
if "PanicException" in error:
|
||||||
must_close = True
|
self.fatal_error_encountered = True
|
||||||
txt = markdown(
|
txt = markdown(
|
||||||
"**A fatal error occurred, and Anki must close. Please report this message on the forums.**"
|
"**A fatal error occurred, and Anki must close. Please report this message on the forums.**"
|
||||||
)
|
)
|
||||||
|
@ -135,7 +138,7 @@ class ErrorHandler(QObject):
|
||||||
# show dialog
|
# show dialog
|
||||||
txt = f"{txt}<div style='white-space: pre-wrap'>{error}</div>"
|
txt = f"{txt}<div style='white-space: pre-wrap'>{error}</div>"
|
||||||
showText(txt, type="html", copyBtn=True)
|
showText(txt, type="html", copyBtn=True)
|
||||||
if must_close:
|
if self.fatal_error_encountered:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def _addonText(self, error: str) -> str:
|
def _addonText(self, error: str) -> str:
|
||||||
|
|
Loading…
Reference in a new issue