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, AudioFX,
XMLLoadCommand, XMLLoadCommand,
AircraftSystems, AircraftSystems,
InputDeviceConfig InputDeviceConfig,
AITrafficSchedule,
AirportDataLoad // ground-net, jetways, etc
}; };
/** /**
@brief Define an error-reporting context value, for the duration of this @brief Define an error-reporting context value, for the duration of this

View File

@ -566,11 +566,14 @@ sgLoad3DModel_internal(const SGPath& path,
if (!texturePathStr.empty()) if (!texturePathStr.empty())
{ {
texturepath = SGModelLib::findDataFile(texturePathStr, NULL, modelDir); 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 + "'", throw sg_io_exception("Texture file not found: '" + texturePathStr + "'",
path); path);
} }
} }
}
} else { } else {
model = new osg::Node; model = new osg::Node;
} }
@ -667,6 +670,9 @@ sgLoad3DModel_internal(const SGPath& path,
if (submodelPath.isNull()) { if (submodelPath.isNull()) {
SG_LOG(SG_IO, SG_DEV_ALERT, "Failed to load file: \"" << subPathStr << "\""); 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; continue;
} }
@ -679,6 +685,8 @@ sgLoad3DModel_internal(const SGPath& path,
} }
} }
simgear::ErrorReportContext("submodel", submodelPath.utf8Str());
try { try {
int num_anims; int num_anims;
std::tie(num_anims, submodel) = sgLoad3DModel_internal(submodelPath, options.get(), std::tie(num_anims, submodel) = sgLoad3DModel_internal(submodelPath, options.get(),