mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
fix: log error if file open/commit fails
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
09823dbb4a
commit
838687fb2e
23 changed files with 54 additions and 44 deletions
|
|
@ -104,7 +104,7 @@ bool loadAssetsIndexJson(const QString& assetsId, const QString& path, AssetsInd
|
|||
// Try to open the file and fail if we can't.
|
||||
// TODO: We should probably report this error to the user.
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << "Failed to read assets index file" << path;
|
||||
qCritical() << "Failed to read assets index file" << path << "error:" << file.errorString();
|
||||
return false;
|
||||
}
|
||||
index.id = assetsId;
|
||||
|
|
|
|||
|
|
@ -144,13 +144,13 @@ bool saveJsonFile(const QJsonDocument& doc, const QString& filename)
|
|||
auto data = doc.toJson();
|
||||
QSaveFile jsonFile(filename);
|
||||
if (!jsonFile.open(QIODevice::WriteOnly)) {
|
||||
qWarning() << "Couldn't open" << filename << "for writing:" << jsonFile.errorString();
|
||||
jsonFile.cancelWriting();
|
||||
qWarning() << "Couldn't open" << filename << "for writing";
|
||||
return false;
|
||||
}
|
||||
jsonFile.write(data);
|
||||
if (!jsonFile.commit()) {
|
||||
qWarning() << "Couldn't save" << filename;
|
||||
qWarning() << "Couldn't save" << filename << "error:" << jsonFile.errorString();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ bool createInstanceShortcut(const Shortcut& shortcut, const QString& filePath)
|
|||
|
||||
QFile iconFile(iconPath);
|
||||
if (!iconFile.open(QFile::WriteOnly)) {
|
||||
QMessageBox::critical(shortcut.parent, QObject::tr("Create Shortcut"), QObject::tr("Failed to create icon for application."));
|
||||
QMessageBox::critical(shortcut.parent, QObject::tr("Create Shortcut"), QObject::tr("Failed to create icon for application: %1").arg(iconFile.errorString()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ bool createInstanceShortcut(const Shortcut& shortcut, const QString& filePath)
|
|||
|
||||
QFile iconFile(iconPath);
|
||||
if (!iconFile.open(QFile::WriteOnly)) {
|
||||
QMessageBox::critical(shortcut.parent, QObject::tr("Create Shortcut"), QObject::tr("Failed to create icon for shortcut."));
|
||||
QMessageBox::critical(shortcut.parent, QObject::tr("Create Shortcut"), QObject::tr("Failed to create icon for shortcut: %1").arg(iconFile.errorString()));
|
||||
return false;
|
||||
}
|
||||
bool success = icon->icon().pixmap(64, 64).save(&iconFile, "PNG");
|
||||
|
|
@ -127,7 +127,7 @@ bool createInstanceShortcut(const Shortcut& shortcut, const QString& filePath)
|
|||
|
||||
QFile iconFile(iconPath);
|
||||
if (!iconFile.open(QFile::WriteOnly)) {
|
||||
QMessageBox::critical(shortcut.parent, QObject::tr("Create Shortcut"), QObject::tr("Failed to create icon for shortcut."));
|
||||
QMessageBox::critical(shortcut.parent, QObject::tr("Create Shortcut"), QObject::tr("Failed to create icon for shortcut: %1").arg(iconFile.errorString()));
|
||||
return false;
|
||||
}
|
||||
bool success = icon->icon().pixmap(64, 64).save(&iconFile, "ICO");
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ bool AccountList::loadList()
|
|||
// Try to open the file and fail if we can't.
|
||||
// TODO: We should probably report this error to the user.
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
qCritical() << QString("Failed to read the account list file (%1).").arg(m_listFilePath).toUtf8();
|
||||
qCritical() << QString("Failed to read the account list file %1 (%2).").arg(m_listFilePath).arg(file.errorString()).toUtf8();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -567,7 +567,7 @@ bool AccountList::saveList()
|
|||
// Try to open the file and fail if we can't.
|
||||
// TODO: We should probably report this error to the user.
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qCritical() << QString("Failed to read the account list file (%1).").arg(m_listFilePath).toUtf8();
|
||||
qCritical() << QString("Failed to save the account list file %1 (%2).").arg(m_listFilePath).arg(file.errorString()).toUtf8();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ bool AccountList::saveList()
|
|||
qDebug() << "Saved account list to" << m_listFilePath;
|
||||
return true;
|
||||
} else {
|
||||
qDebug() << "Failed to save accounts to" << m_listFilePath;
|
||||
qDebug() << "Failed to save accounts to" << m_listFilePath << "error:" << file.errorString();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ bool loadIconFile(const Mod& mod, QPixmap* pixmap)
|
|||
if (icon_info.exists() && icon_info.isFile()) {
|
||||
QFile icon(icon_info.filePath());
|
||||
if (!icon.open(QIODevice::ReadOnly)) {
|
||||
return png_invalid("failed to open file " + icon_info.filePath());
|
||||
return png_invalid("failed to open file " + icon_info.filePath() + " " + icon.errorString());
|
||||
}
|
||||
auto data = icon.readAll();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue