Add better logging for file open and write errors

This commit is contained in:
Jonas Kvinge
2021-08-09 23:32:26 +02:00
parent 7d61d8e646
commit f1d3cadb3b
15 changed files with 120 additions and 41 deletions

View File

@@ -281,7 +281,7 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
// It's a local file, so check if it looks like a playlist. Read the first few bytes.
QFile file(filename);
if (!file.open(QIODevice::ReadOnly)) {
errors_ << tr("Could not open file %1").arg(filename);
errors_ << tr("Could not open file %1 for reading: %2").arg(filename).arg(file.errorString());
return Error;
}
QByteArray data(file.read(PlaylistParser::kMagicSize));
@@ -312,6 +312,10 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
}
return Success;
}
else {
errors_ << tr("Could not open CUE file %1 for reading: %2").arg(matching_cue).arg(cue.errorString());
return Error;
}
}
// Assume it's just a normal file
@@ -364,6 +368,9 @@ void SongLoader::LoadPlaylist(ParserBase *parser, const QString &filename) {
songs_ = parser->Load(&file, filename, QFileInfo(filename).path());
file.close();
}
else {
errors_ << tr("Could not open playlist file %1 for reading: %2").arg(filename).arg(file.errorString());
}
}