Fix showing IO error in Qt Quick GUI

The order of the catch handlers must be adjusted because
std::ios_base::failure is derived from std::runtime_error.
This commit is contained in:
Martchus 2020-03-28 23:13:34 +01:00
parent c12f63dac1
commit 1c6230dbeb
4 changed files with 38 additions and 42 deletions

View File

@ -15,7 +15,7 @@ set(META_USE_QQC2 ON)
set(META_ANDROID_PACKAGE_NAME "org.martchus.passwordmanager")
set(META_VERSION_MAJOR 4)
set(META_VERSION_MINOR 1)
set(META_VERSION_PATCH 3)
set(META_VERSION_PATCH 4)
set(PNG_ICON_NO_CROP ON)
# add project files

View File

@ -142,8 +142,6 @@ void Controller::load()
clearPassword();
emit fileError(tr("A crypto error occured when opening the file: ") + QString::fromLocal8Bit(e.what()), QStringLiteral("load"));
}
} catch (const runtime_error &e) {
emit fileError(tr("A parsing error occured when opening the file: ") + QString::fromLocal8Bit(e.what()), QStringLiteral("load"));
} catch (...) {
emitFileError(tr("loading"));
}
@ -226,8 +224,6 @@ void Controller::save()
emit fileSaved();
} catch (const CryptoException &e) {
emit fileError(tr("A crypto error occured when saving the file: ") + QString::fromLocal8Bit(e.what()), QStringLiteral("save"));
} catch (const runtime_error &e) {
emit fileError(tr("An internal error occured when saving the file: ") + QString::fromLocal8Bit(e.what()), QStringLiteral("save"));
} catch (...) {
emitFileError(tr("saving"));
}
@ -450,6 +446,8 @@ void Controller::emitFileError(const QString &when)
} catch (const std::ios_base::failure &failure) {
emit fileError(
tr("An IO error occured when %1 the file %2: ").arg(when, m_filePath) + QString::fromLocal8Bit(failure.what()), QStringLiteral("load"));
} catch (const runtime_error &e) {
emit fileError(tr("An error occured when %1 the file: ").arg(when) + QString::fromLocal8Bit(e.what()), QStringLiteral("save"));
} catch (const exception &e) {
emit fileError(tr("An unknown exception occured when %1 the file %2: ").arg(when, m_filePath) + QString::fromLocal8Bit(e.what()),
QStringLiteral("load"));

View File

@ -267,43 +267,41 @@
<translation>Ein Verschlüsselungsfehler ist beim Öffnen der Datei aufgetreten: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="146"/>
<source>A parsing error occured when opening the file: </source>
<translation>Die Datei konnte nicht richtig eingelesen werden: </translation>
<translation type="vanished">Die Datei konnte nicht richtig eingelesen werden: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="148"/>
<location filename="../quickgui/controller.cpp" line="146"/>
<source>loading</source>
<translation>beim Laden</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="157"/>
<location filename="../quickgui/controller.cpp" line="155"/>
<source>creating</source>
<translation>beim Erstellen</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="172"/>
<location filename="../quickgui/controller.cpp" line="181"/>
<location filename="../quickgui/controller.cpp" line="170"/>
<location filename="../quickgui/controller.cpp" line="179"/>
<source>closing</source>
<translation>beim Schließen</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="213"/>
<location filename="../quickgui/controller.cpp" line="211"/>
<source>Unable to open file descriptor for saving the file.</source>
<translation>Fehler beim Öffnen des Dateideskriptors zum Speichern der Datei.</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="228"/>
<location filename="../quickgui/controller.cpp" line="226"/>
<source>A crypto error occured when saving the file: </source>
<translation>Ein Verschlüsselungsfehler ist beim Speichern der Datei aufgetreten: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="230"/>
<source>An internal error occured when saving the file: </source>
<translation>Ein interner Fehler ist beim Speichern der Datei aufgetreten: </translation>
<translation type="vanished">Ein interner Fehler ist beim Speichern der Datei aufgetreten: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="232"/>
<location filename="../quickgui/controller.cpp" line="228"/>
<source>saving</source>
<translation>beim Speichern</translation>
</message>
@ -312,27 +310,32 @@
<translation type="vanished">beim Öffnen mittels nativem Dateideskriptors</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="308"/>
<location filename="../quickgui/controller.cpp" line="304"/>
<source>Canceled file selection</source>
<translation>Dateiauswahl geschlossen</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="435"/>
<location filename="../quickgui/controller.cpp" line="431"/>
<source>No file opened.</source>
<translation>Keine Datei geöffnet.</translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="452"/>
<location filename="../quickgui/controller.cpp" line="448"/>
<source>An IO error occured when %1 the file %2: </source>
<translation>Ein Ein- bzw. Ausgabefehler ist %1 der Datei %2 aufgetreten: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="454"/>
<location filename="../quickgui/controller.cpp" line="450"/>
<source>An error occured when %1 the file: </source>
<translation>Ein Fehler ist %1 der Datei aufgetreten: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="452"/>
<source>An unknown exception occured when %1 the file %2: </source>
<translation>Eine unbekannte Ausnahme ist %1 der Datei %2 aufgetreten: </translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="457"/>
<location filename="../quickgui/controller.cpp" line="455"/>
<source>An unknown error occured when %1 the file %2.</source>
<translation>Ein unbekannter Fehler ist %1 der Datei %2 aufgetreten.</translation>
</message>

View File

@ -230,67 +230,62 @@
</message>
<message>
<location filename="../quickgui/controller.cpp" line="146"/>
<source>A parsing error occured when opening the file: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="148"/>
<source>loading</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="157"/>
<location filename="../quickgui/controller.cpp" line="155"/>
<source>creating</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="172"/>
<location filename="../quickgui/controller.cpp" line="181"/>
<location filename="../quickgui/controller.cpp" line="170"/>
<location filename="../quickgui/controller.cpp" line="179"/>
<source>closing</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="213"/>
<location filename="../quickgui/controller.cpp" line="211"/>
<source>Unable to open file descriptor for saving the file.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="228"/>
<location filename="../quickgui/controller.cpp" line="226"/>
<source>A crypto error occured when saving the file: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="230"/>
<source>An internal error occured when saving the file: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="232"/>
<location filename="../quickgui/controller.cpp" line="228"/>
<source>saving</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="308"/>
<location filename="../quickgui/controller.cpp" line="304"/>
<source>Canceled file selection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="435"/>
<location filename="../quickgui/controller.cpp" line="431"/>
<source>No file opened.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="452"/>
<location filename="../quickgui/controller.cpp" line="448"/>
<source>An IO error occured when %1 the file %2: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="454"/>
<location filename="../quickgui/controller.cpp" line="450"/>
<source>An error occured when %1 the file: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="452"/>
<source>An unknown exception occured when %1 the file %2: </source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../quickgui/controller.cpp" line="457"/>
<location filename="../quickgui/controller.cpp" line="455"/>
<source>An unknown error occured when %1 the file %2.</source>
<translation type="unfinished"></translation>
</message>