Improve logging for errors

This commit also allows the strings to be translated.
This commit is contained in:
Chocobo1 2020-03-31 20:40:03 +08:00
parent 96c5af7ae9
commit 17f608685d
No known key found for this signature in database
GPG key ID: 210D9C873253A68C

View file

@ -44,12 +44,9 @@ void ResumeDataSavingManager::save(const QString &filename, const QByteArray &da
const QString filepath = m_resumeDataDir.absoluteFilePath(filename);
QSaveFile file {filepath};
if (file.open(QIODevice::WriteOnly)) {
file.write(data);
if (!file.commit()) {
Logger::instance()->addMessage(QString("Couldn't save data in '%1'. Error: %2")
.arg(filepath, file.errorString()), Log::WARNING);
}
if (!file.open(QIODevice::WriteOnly) || (file.write(data) != data.size()) || !file.commit()) {
LogMsg(tr("Couldn't save data to '%1'. Error: %2")
.arg(filepath, file.errorString()), Log::CRITICAL);
}
}