From 1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 21 Feb 2016 01:44:27 +0100 Subject: GH-1453 report version file problems in the version page --- logic/minecraft/ProfileUtils.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'logic/minecraft/ProfileUtils.cpp') 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); } -- cgit v1.2.3