Error reporting for submodels

Also add some error codes I forgot for AI and traffic.
This commit is contained in:
James Turner 2021-02-21 19:16:53 +00:00
parent b8b88995cf
commit 93e2bccb0e
2 changed files with 12 additions and 2 deletions

View File

@ -57,7 +57,9 @@ enum class ErrorCode {
AudioFX,
XMLLoadCommand,
AircraftSystems,
InputDeviceConfig
InputDeviceConfig,
AITrafficSchedule,
AirportDataLoad // ground-net, jetways, etc
};
/**
@brief Define an error-reporting context value, for the duration of this

View File

@ -566,9 +566,12 @@ sgLoad3DModel_internal(const SGPath& path,
if (!texturePathStr.empty())
{
texturepath = SGModelLib::findDataFile(texturePathStr, NULL, modelDir);
if (texturepath.isNull())
if (texturepath.isNull()) {
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::LoadingTexture,
"Texture file not found:" + texturePathStr, path);
throw sg_io_exception("Texture file not found: '" + texturePathStr + "'",
path);
}
}
}
} else {
@ -667,6 +670,9 @@ sgLoad3DModel_internal(const SGPath& path,
if (submodelPath.isNull()) {
SG_LOG(SG_IO, SG_DEV_ALERT, "Failed to load file: \"" << subPathStr << "\"");
simgear::reportFailure(simgear::LoadFailure::NotFound, simgear::ErrorCode::XMLModelLoad,
"Couldn't find file for submodel:" + subPathStr,
SGPath::fromUtf8(subPathStr));
continue;
}
@ -679,6 +685,8 @@ sgLoad3DModel_internal(const SGPath& path,
}
}
simgear::ErrorReportContext("submodel", submodelPath.utf8Str());
try {
int num_anims;
std::tie(num_anims, submodel) = sgLoad3DModel_internal(submodelPath, options.get(),