Made resource loading fail gracefully when a resource can't be loaded. Resources should now throw exceptions in their constuctor if the resource can't be loaded. This will result in ResourceManager::Load returning null.

This commit is contained in:
2015-12-13 20:04:50 +01:00
parent 91ace0d2a0
commit 524af211e0
3 changed files with 15 additions and 6 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ RawModel::RawModel(std::string fileName)
if (scene == nullptr) {
LOG_ERROR("Failed to load model \"%s\"", fileName.c_str());
LOG_ERROR("Assimp error: %s", importer.GetErrorString());
return;
throw std::runtime_error("Failed to open model file.");
}
auto m = scene->mRootNode->mTransformation;
@@ -77,6 +77,9 @@ void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)
}
glm::vec4 color = modelC["Color"];
Model* model = ResourceManager::Load<Model>(resource);
if (model == nullptr) {
model = ResourceManager::Load<Model>("Models/Core/Error.obj");
}
for (auto texGroup : model->TextureGroups) {
ModelJob job;