]> git.tdb.fi Git - libs/gl.git/blobdiff - source/resourcemanager.cpp
Throw a resource_load_error if the source could not be opened
[libs/gl.git] / source / resourcemanager.cpp
index e989a5d07b0f5a1d3c2d148257f94694cfc7b08e..733cfaff8c4c37ba5ae1ffbd605ceb3f8d6a58df 100644 (file)
@@ -11,6 +11,10 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
+resource_load_error::resource_load_error(const string &name, const string &err):
+       runtime_error(format("%s: %s", name, err))
+{ }
+
 resource_load_error::resource_load_error(const string &name, const exception &exc):
        runtime_error(format("%s: %s: %s", name, Debug::demangle(typeid(exc).name()), exc.what()))
 { }
@@ -276,6 +280,9 @@ ResourceManager::ManagedResource::ManagedResource(Resource &r):
 void ResourceManager::ManagedResource::start_loading()
 {
        io = location.collection->open_raw(location.name);
+       if(!io)
+               throw resource_load_error(location.name, "open failed");
+
        loader = resource->load(*io);
        if(!loader)
        {