summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/ProfileUtils.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-02-21 01:44:27 +0100
committerPetr Mrázek <peterix@gmail.com>2016-02-21 01:44:27 +0100
commit1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae (patch)
tree2c2fbc7a74ea5035fdfd8752272e011852eb1b85 /logic/minecraft/ProfileUtils.cpp
parent495d320ce267cf6d7c7e4468dbc36d3536bcb401 (diff)
downloadMultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar.gz
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar.lz
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar.xz
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.zip
GH-1453 report version file problems in the version page
Diffstat (limited to 'logic/minecraft/ProfileUtils.cpp')
-rw-r--r--logic/minecraft/ProfileUtils.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/logic/minecraft/ProfileUtils.cpp b/logic/minecraft/ProfileUtils.cpp
index 9a886f1d..5816f207 100644
--- a/logic/minecraft/ProfileUtils.cpp
+++ b/logic/minecraft/ProfileUtils.cpp
@@ -107,13 +107,26 @@ VersionFilePtr parseJsonFile(const QFileInfo &fileInfo, const bool requireOrder)
.arg(fileInfo.fileName(), file.errorString()));
}
QJsonParseError error;
- QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &error);
+ auto data = file.readAll();
+ QJsonDocument doc = QJsonDocument::fromJson(data, &error);
if (error.error != QJsonParseError::NoError)
{
+ int line = 0;
+ int column = 0;
+ for(int i = 0; i < error.offset; i++)
+ {
+ if(data[i] == '\n')
+ {
+ line++;
+ column = 0;
+ continue;
+ }
+ column++;
+ }
throw JSONValidationError(
- QObject::tr("Unable to process the version file %1: %2 at %3.")
+ QObject::tr("Unable to process the version file %1: %2 at line %3 column %4.")
.arg(fileInfo.fileName(), error.errorString())
- .arg(error.offset));
+ .arg(line).arg(column));
}
return VersionFile::fromJson(doc, file.fileName(), requireOrder);
}