1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-05-04 10:27:44 +02:00

Improved error reporting

This commit is contained in:
Martin Tůma 2025-04-30 23:05:04 +02:00
parent ba50e67380
commit ed4c18b773
5 changed files with 19 additions and 16 deletions

View File

@ -259,13 +259,9 @@ bool ISO8211::readUDA(quint64 pos, const FieldDefinition &def,
bool ISO8211::readRecord(Record &record)
{
if (_file.atEnd())
return false;
QVector<FieldDefinition> fields;
qint64 pos = _file.pos();
if (readDR(fields) < 0) {
_errorString = "Error reading DR";
return false;

View File

@ -35,6 +35,7 @@ public:
ISO8211(const QString &path) : _file(path) {}
bool readDDR();
bool readRecord(Record &record);
bool atEnd() const {return _file.atEnd();}
const QString &errorString() const {return _errorString;}
static constexpr quint32 NAME(const char str[4])

View File

@ -829,9 +829,15 @@ MapData::MapData(const QString &path)
if (!ddf.readDDR())
return;
while (ddf.readRecord(record))
while (!ddf.atEnd()) {
if (!ddf.readRecord(record)) {
qWarning("%s: %s", qUtf8Printable(path),
qUtf8Printable(ddf.errorString()));
break;
}
if (!processRecord(record, fe, vi, vc, ve, comf, somf, huni))
qWarning("Invalid S-57 record");
qWarning("%s: Invalid S-57 record", qUtf8Printable(path));
}
for (int i = 0; i < fe.size(); i++) {
const ISO8211::Record &r = fe.at(i);

View File

@ -127,14 +127,14 @@ ENCAtlas::ENCAtlas(const QString &fileName, QObject *parent)
_errorString = ddf.errorString();
return;
}
while (ddf.readRecord(record)) {
while (!ddf.atEnd()) {
if (!ddf.readRecord(record)) {
_errorString = ddf.errorString();
return;
}
if (processRecord(record, file, bounds))
addMap(dir, file, bounds);
}
if (!ddf.errorString().isNull()) {
_errorString = ddf.errorString();
return;
}
if (_data.isEmpty()) {
_errorString = "No usable ENC map found";

View File

@ -143,16 +143,16 @@ ENCMap::ENCMap(const QString &fileName, QObject *parent)
_errorString = ddf.errorString();
return;
}
while (ddf.readRecord(record)) {
while (!ddf.atEnd()) {
if (!ddf.readRecord(record)) {
_errorString = ddf.errorString();
return;
}
if (!processRecord(record, gv, comf, dsnm)) {
_errorString = "Invalid S-57 record";
return;
}
}
if (!ddf.errorString().isNull()) {
_errorString = ddf.errorString();
return;
}
_name = dsnm;