Add more error messages encouraging bug reports

Julien LepillerSun Aug 29 22:05:14+0200 2021

ba43d47

Add more error messages encouraging bug reports

CHANGELOG.md

1111
* The internals have been refactored. The most visible difference is in
1212
  settings handling: systems define the settings they need, instead of having
1313
  this information spread everywhere.
14+
* When a crash happens, suggest sending a bug report and show traceback. Obviously,
15+
  it would be much better to fix the actual crashes :-)
1416
1517
### Bug fixes ###
1618

offlate/data/common.py unknown status 1

1+
REPO = 'https://framagit.org/tyreunom/offlate/issues'
2+
EMAIL = 'bug-offlate@lepiller.eu'

offlate/locales/offlate_en.ts

33
<context>
44
    <name>AboutWindow</name>
55
    <message>
6-
        <location filename="../ui/about.py" line="43"/>
6+
        <location filename="../ui/about.py" line="45"/>
77
        <source>Offlate is a translation interface for offline translation of projects using online platforms. Offlate is free software, you can redistribute it under the GPL v3 license or any later version.</source>
88
        <translation>Offlate is a translation interface for offline translation of projects using online platforms. Offlate is free software, you can redistribute it under the GPL v3 license or any later version.</translation>
99
    </message>

1313
        <translation type="obsolete">Copyright ?? 2018, 2019 Julien Lepiller</translation>
1414
    </message>
1515
    <message>
16-
        <location filename="../ui/about.py" line="51"/>
16+
        <location filename="../ui/about.py" line="53"/>
1717
        <source>Report an issue</source>
1818
        <translation>Report an issue</translation>
1919
    </message>
2020
    <message>
21-
        <location filename="../ui/about.py" line="52"/>
21+
        <location filename="../ui/about.py" line="54"/>
2222
        <source>Close this window</source>
2323
        <translation>Close this window</translation>
2424
    </message>
2525
    <message>
26-
        <location filename="../ui/about.py" line="49"/>
26+
        <location filename="../ui/about.py" line="51"/>
2727
        <source>Copyright (C) 2018-2021 Julien Lepiller</source>
2828
        <translation type="unfinished"></translation>
2929
    </message>

584584
    </message>
585585
</context>
586586
<context>
587+
    <name>dialog</name>
588+
    <message>
589+
        <location filename="../ui/main.py" line="59"/>
590+
        <source>The app just crashed, please report thefollowing error, with any relevant information (what you didwhen the app crashed, any external factor that might be relevant,etc.). You can send your report on {}, or by email to {}.
591+
592+
{}
593+
Traceback:
594+
{}</source>
595+
        <translation type="unfinished"></translation>
596+
    </message>
597+
</context>
598+
<context>
587599
    <name>self.parent</name>
588600
    <message>
589-
        <location filename="../ui/parallel.py" line="52"/>
601+
        <location filename="../ui/parallel.py" line="57"/>
590602
        <source>A project with the same name already exists. The new project was not created. You should first remove the same-named project.</source>
591603
        <translation>A project with the same name already exists. The new project was not created. You should first remove the same-named project.</translation>
592604
    </message>
593605
    <message>
594-
        <location filename="../ui/parallel.py" line="56"/>
606+
        <location filename="../ui/parallel.py" line="61"/>
595607
        <source>Your filesystem contains a same-named directory for your new project. The new project was not created. You should first remove the same-named directory: &quot;{}&quot;.</source>
596608
        <translation>Your filesystem contains a same-named directory for your new project. The new project was not created. You should first remove the same-named directory: ???{}???.</translation>
597609
    </message>
598610
    <message>
599-
        <location filename="../ui/parallel.py" line="62"/>
611+
        <location filename="../ui/parallel.py" line="67"/>
600612
        <source>The project you added uses the {} format, but it is not supported yet by Offlate. You can try to update the application, or if you are on the latest version already, report it as a bug.</source>
601613
        <translation>The project you added uses the {} format, but it is not supported yet by Offlate. You can try to update the application, or if you are on the latest version already, report it as a bug.</translation>
602614
    </message>
603615
    <message>
604-
        <location filename="../ui/parallel.py" line="70"/>
616+
        <location filename="../ui/parallel.py" line="75"/>
605617
        <source>An unexpected error occured while fetching the project: {}. You should report this as a bug.</source>
606618
        <translation>An unexpected error occured while fetching the project: {}. You should report this as a bug.</translation>
607619
    </message>
608620
    <message>
609-
        <location filename="../ui/parallel.py" line="66"/>
621+
        <location filename="../ui/parallel.py" line="71"/>
610622
        <source>The project {} you added could not be found in the translation platform you selected. Did you make a typo while entering the name or other parameters?</source>
611623
        <translation>The project {} you added could not be found in the translation platform you selected. Did you make a typo while entering the name or other parameters?</translation>
612624
    </message>
613625
    <message>
614-
        <location filename="../ui/parallel.py" line="46"/>
615-
        <source>This action did not complete correctly. We received the following error message: {}.
626+
        <location filename="../ui/parallel.py" line="48"/>
627+
        <source>This action did not complete correctly. Try again, and if the issue persists, consider sending a bug report at {}, or by email to {} with the following information, and any relevant information (what you were trying to do, other external factors, etc.) We received the following error message: {}.
616628
617629
Traceback:
618630

offlate/locales/offlate_fr.ts

33
<context>
44
    <name>AboutWindow</name>
55
    <message>
6-
        <location filename="../ui/about.py" line="43"/>
6+
        <location filename="../ui/about.py" line="45"/>
77
        <source>Offlate is a translation interface for offline translation of projects using online platforms. Offlate is free software, you can redistribute it under the GPL v3 license or any later version.</source>
88
        <translation>Offlate est une interface de traduction hors-ligne de projets qui utilisent des plateformes en ligne. Offlate est un logiciel libre, vous pouvez le redistribuer sous la licence GPL v3 ou toute version ult??rieure.</translation>
99
    </message>
1010
    <message>
11-
        <location filename="../ui/about.py" line="51"/>
11+
        <location filename="../ui/about.py" line="53"/>
1212
        <source>Report an issue</source>
1313
        <translation>Rapporter un probl??me</translation>
1414
    </message>
1515
    <message>
16-
        <location filename="../ui/about.py" line="52"/>
16+
        <location filename="../ui/about.py" line="54"/>
1717
        <source>Close this window</source>
1818
        <translation>Fermer cette fen??tre</translation>
1919
    </message>

2525
Copyright ?? 2018, 2019 Julien Lepiller</translation>
2626
    </message>
2727
    <message>
28-
        <location filename="../ui/about.py" line="49"/>
28+
        <location filename="../ui/about.py" line="51"/>
2929
        <source>Copyright (C) 2018-2021 Julien Lepiller</source>
3030
        <translation type="unfinished"></translation>
3131
    </message>

586586
    </message>
587587
</context>
588588
<context>
589+
    <name>dialog</name>
590+
    <message>
591+
        <location filename="../ui/main.py" line="59"/>
592+
        <source>The app just crashed, please report thefollowing error, with any relevant information (what you didwhen the app crashed, any external factor that might be relevant,etc.). You can send your report on {}, or by email to {}.
593+
594+
{}
595+
Traceback:
596+
{}</source>
597+
        <translation type="unfinished"></translation>
598+
    </message>
599+
</context>
600+
<context>
589601
    <name>self.parent</name>
590602
    <message>
591-
        <location filename="../ui/parallel.py" line="52"/>
603+
        <location filename="../ui/parallel.py" line="57"/>
592604
        <source>A project with the same name already exists. The new project was not created. You should first remove the same-named project.</source>
593605
        <translation>Il existe d??j?? un projet avec le m??me nom. Le nouveau projet n&apos;a pas ??t?? cr????. Vous devriez supprimer le projet qui a le m??me nom.</translation>
594606
    </message>
595607
    <message>
596-
        <location filename="../ui/parallel.py" line="56"/>
608+
        <location filename="../ui/parallel.py" line="61"/>
597609
        <source>Your filesystem contains a same-named directory for your new project. The new project was not created. You should first remove the same-named directory: &quot;{}&quot;.</source>
598610
        <translation>Votre syst??me de fichiers contient d??j?? un r??pertoire avec le m??me nom que votre nouveau projet. Le nouveau projet n&apos;a pas ??t?? cr????. Vous devriez d&apos;abord supprimer le r??pertoire avec le m??me nom : ?? {} ??.</translation>
599611
    </message>
600612
    <message>
601-
        <location filename="../ui/parallel.py" line="62"/>
613+
        <location filename="../ui/parallel.py" line="67"/>
602614
        <source>The project you added uses the {} format, but it is not supported yet by Offlate. You can try to update the application, or if you are on the latest version already, report it as a bug.</source>
603615
        <translation>Le projet que vous avez ajout?? utilise le format {}, mais il n&apos;est pas encore pris en charge par Offlate. Vous pouvez essayer de mettre ?? jour l&apos;application, ou si vous ??tes d??j?? sur la derni??re version, rapportez un bogue.</translation>
604616
    </message>
605617
    <message>
606-
        <location filename="../ui/parallel.py" line="70"/>
618+
        <location filename="../ui/parallel.py" line="75"/>
607619
        <source>An unexpected error occured while fetching the project: {}. You should report this as a bug.</source>
608620
        <translation>Une erreur inattendue a eu lieue lors de la r??cup??ration du projet : {}. Vous devriez rapporter un bogue.</translation>
609621
    </message>
610622
    <message>
611-
        <location filename="../ui/parallel.py" line="66"/>
623+
        <location filename="../ui/parallel.py" line="71"/>
612624
        <source>The project {} you added could not be found in the translation platform you selected. Did you make a typo while entering the name or other parameters?</source>
613625
        <translation>Le projet {} que vous avez ajout?? n&apos;a pas ??t?? trouv?? sur la plateforme de traduction de vous avez choisie. Avez-vous fait une coquille en tapant son nom ou d&apos;autres param??tres ?</translation>
614626
    </message>
615627
    <message>
616-
        <location filename="../ui/parallel.py" line="46"/>
617-
        <source>This action did not complete correctly. We received the following error message: {}.
628+
        <location filename="../ui/parallel.py" line="48"/>
629+
        <source>This action did not complete correctly. Try again, and if the issue persists, consider sending a bug report at {}, or by email to {} with the following information, and any relevant information (what you were trying to do, other external factors, etc.) We received the following error message: {}.
618630
619631
Traceback:
620632

offlate/ui/about.py

2121
from PyQt5.QtGui import *
2222
from PyQt5.QtCore import *
2323
24+
from ..data.common import REPO
25+
2426
class AboutWindow(QDialog):
2527
    def __init__(self, parent = None):
2628
        super().__init__(parent)

6769
        issue_button.clicked.connect(self.issue)
6870
6971
    def issue(self):
70-
        webbrowser.open('https://framagit.org/tyreunom/offlate/issues')
72+
        webbrowser.open(REPO)

offlate/ui/main.py

2121
from .manager import ProjectManagerWindow
2222
from .config.welcome import WelcomeWindow
2323
24+
from ..data.common import REPO, EMAIL
25+
2426
import sys
2527
import os
2628

4244
        return
4345
4446
    w.projectManagerWidget.manager.setNotNew()
45-
    w.show()
46-
47-
    sys.exit(app.exec_())
47+
    try:
48+
        w.show()
49+
        exit = app.exec_()
50+
    except:
51+
        info = sys.exc_info()
52+
        traceback = ''
53+
        trace = info[2]
54+
        while trace is not None:
55+
            traceback = traceback + str(trace.tb_frame) + "\n"
56+
            trace = trace.tb_next
57+
        dialog = QMessageBox()
58+
        dialog.setWindowTitle("Fatal error")
59+
        dialog.setText(
60+
            dialog.tr("The app just crashed, please report the\
61+
following error, with any relevant information (what you did\
62+
when the app crashed, any external factor that might be relevant,\
63+
etc.). You can send your report on {}, or by email to {}.\n\n{}\n\
64+
Traceback:\n{}").format(REPO, EMAIL, info[1], traceback))
65+
        dialog.setStandardButtons(QMessageBox.Close)
66+
        dialog.exec_()
67+
        exit = 1
68+
    sys.exit(exit)

offlate/ui/parallel.py

2121
from ..systems.exception import ProjectNotFoundSystemException
2222
from ..systems.callback import SystemCallback
2323
24+
from ..data.common import REPO, EMAIL
25+
2426
import sys
2527
2628
class RunnableCallback(SystemCallback, QRunnable):

4446
            trace = trace.tb_next
4547
4648
        self.error = self.parent.tr('This action did not complete correctly. \
47-
We received the following error message: {}.\n\nTraceback:\n\n{}\nTry \
48-
again?'.format(error, traceback))
49+
Try again, and if the issue persists, consider sending a bug report at {}, or \
50+
by email to {} with the following information, and any relevant information \
51+
(what you were trying to do, other external factors, etc.) We received the \
52+
following error message: {}.\n\nTraceback:\n\n{}\nTry again?'.format(REPO,
53+
            EMAIL, error, traceback))
4954
        self.signals.error.emit(self.name, self.error)
5055
5156
    def project_exists(self):