mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Improved error reporting
This commit is contained in:
parent
efd496d38c
commit
8b4daa43e3
@ -121,6 +121,13 @@ Data::Data(const QString &fileName, bool tryUnknown)
|
|||||||
file.reset();
|
file.reset();
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qWarning("%s:", qPrintable(fileName));
|
||||||
|
for (it = _parsers.find(suffix); it != _parsers.end()
|
||||||
|
&& it.key() == suffix; it++)
|
||||||
|
qWarning(" %s: line %d: %s", qPrintable(it.key()),
|
||||||
|
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||||
|
|
||||||
} else if (tryUnknown) {
|
} else if (tryUnknown) {
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||||
if (it.value()->parse(&file, trackData, routeData, _polygons,
|
if (it.value()->parse(&file, trackData, routeData, _polygons,
|
||||||
@ -132,9 +139,9 @@ Data::Data(const QString &fileName, bool tryUnknown)
|
|||||||
file.reset();
|
file.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
qWarning("Error loading data file: %s:", qPrintable(fileName));
|
qWarning("%s:", qPrintable(fileName));
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
||||||
qWarning("%s: line %d: %s", qPrintable(it.key()),
|
qWarning(" %s: line %d: %s", qPrintable(it.key()),
|
||||||
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
it.value()->errorLine(), qPrintable(it.value()->errorString()));
|
||||||
|
|
||||||
_errorLine = 0;
|
_errorLine = 0;
|
||||||
|
@ -62,37 +62,36 @@ Map *MapList::loadFile(const QString &path, const Projection &proj, bool *isDir)
|
|||||||
QFileInfo fi(path);
|
QFileInfo fi(path);
|
||||||
QString suffix(fi.suffix().toLower());
|
QString suffix(fi.suffix().toLower());
|
||||||
Map *map = 0;
|
Map *map = 0;
|
||||||
|
QStringList errors;
|
||||||
|
|
||||||
if ((it = _parsers.find(suffix)) != _parsers.end()) {
|
if ((it = _parsers.find(suffix)) != _parsers.end()) {
|
||||||
while (it != _parsers.end() && it.key() == suffix) {
|
while (it != _parsers.end() && it.key() == suffix) {
|
||||||
delete map;
|
delete map;
|
||||||
map = it.value()(path, proj, isDir);
|
map = it.value()(path, proj, isDir);
|
||||||
if (map->isValid())
|
if (map->isValid())
|
||||||
break;
|
return map;
|
||||||
|
else
|
||||||
|
errors.append(it.key() + ": " + map->errorString());
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
QStringList errors;
|
|
||||||
|
|
||||||
|
} else {
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
for (it = _parsers.begin(); it != _parsers.end(); it++) {
|
||||||
map = it.value()(path, proj, isDir);
|
map = it.value()(path, proj, isDir);
|
||||||
if (map->isValid())
|
if (map->isValid())
|
||||||
break;
|
return map;
|
||||||
else {
|
else {
|
||||||
errors.append(it.key() + ": " + map->errorString());
|
errors.append(it.key() + ": " + map->errorString());
|
||||||
delete map;
|
delete map;
|
||||||
map = 0;
|
map = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!map) {
|
|
||||||
qWarning("Error loading map file: %s:", qPrintable(path));
|
|
||||||
for (int i = 0; i < errors.size(); i++)
|
|
||||||
qWarning("%s", qPrintable(errors.at(i)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qWarning("%s:", qPrintable(path));
|
||||||
|
for (int i = 0; i < errors.size(); i++)
|
||||||
|
qWarning(" %s", qPrintable(errors.at(i)));
|
||||||
|
|
||||||
return map ? map : new InvalidMap(path, "Unknown file format");
|
return map ? map : new InvalidMap(path, "Unknown file format");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ WLDFile::WLDFile(const QString &fileName)
|
|||||||
QByteArray line(file.readLine(128).trimmed());
|
QByteArray line(file.readLine(128).trimmed());
|
||||||
val[i] = line.toDouble(&ok);
|
val[i] = line.toDouble(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
_errorString = line + ": invalid parameter";
|
_errorString = QString("Parse error on line %1").arg(i+1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user