From 2541797e7dfc6db1342648e547ff81528e04602c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 31 Dec 2023 01:12:46 +0100 Subject: [PATCH] Improved error reporting --- src/map/IMG/gmapdata.cpp | 4 +++- src/map/bsbmap.cpp | 2 +- src/map/oruxmap.cpp | 4 +++- src/map/qctmap.cpp | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/map/IMG/gmapdata.cpp b/src/map/IMG/gmapdata.cpp index 14e9c11e..712eb65c 100644 --- a/src/map/IMG/gmapdata.cpp +++ b/src/map/IMG/gmapdata.cpp @@ -52,8 +52,10 @@ bool GMAPData::readXML(const QString &path, QString &dataDir, QString &typFile) { QFile file(path); - if (!file.open(QFile::ReadOnly | QFile::Text)) + if (!file.open(QFile::ReadOnly | QFile::Text)) { + _errorString = file.errorString(); return false; + } QXmlStreamReader reader(&file); if (reader.readNextStartElement()) { diff --git a/src/map/bsbmap.cpp b/src/map/bsbmap.cpp index 861f4bd7..eeb44742 100644 --- a/src/map/bsbmap.cpp +++ b/src/map/bsbmap.cpp @@ -395,7 +395,7 @@ BSBMap::BSBMap(const QString &fileName, QObject *parent) QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) { - _errorString = fileName + ": " + file.errorString(); + _errorString = file.errorString(); return; } diff --git a/src/map/oruxmap.cpp b/src/map/oruxmap.cpp index 7d82fb1a..bb0ffdca 100644 --- a/src/map/oruxmap.cpp +++ b/src/map/oruxmap.cpp @@ -366,8 +366,10 @@ bool OruxMap::readXML(const QString &path, const QString &dir) { QFile file(path); - if (!file.open(QFile::ReadOnly | QFile::Text)) + if (!file.open(QFile::ReadOnly | QFile::Text)) { + _errorString = file.errorString(); return false; + } QXmlStreamReader reader(&file); if (reader.readNextStartElement()) { diff --git a/src/map/qctmap.cpp b/src/map/qctmap.cpp index e424c2d4..6d05ef24 100644 --- a/src/map/qctmap.cpp +++ b/src/map/qctmap.cpp @@ -327,7 +327,7 @@ QCTMap::QCTMap(const QString &fileName, QObject *parent) _mapRatio(1.0), _valid(false) { if (!_file.open(QIODevice::ReadOnly)) { - _errorString = fileName + ": " + _file.errorString(); + _errorString = _file.errorString(); return; }