]> git.tdb.fi Git - libs/gl.git/commitdiff
Throw a resource_load_error if the source could not be opened
authorMikko Rasa <tdb@tdb.fi>
Sat, 5 Sep 2015 20:05:22 +0000 (23:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 5 Sep 2015 20:05:22 +0000 (23:05 +0300)
source/resourcemanager.cpp
source/resourcemanager.h

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)
        {
index 5cc427f729cabaa4ec15eec927283d38297f4a68..e7c8c04b3224d87b3eff51686013b9536d2d90a1 100644 (file)
@@ -16,6 +16,7 @@ class ResourceWatcher;
 class resource_load_error: public std::runtime_error
 {
 public:
+       resource_load_error(const std::string &, const std::string &);
        resource_load_error(const std::string &, const std::exception &);
        virtual ~resource_load_error() throw() { }
 };