X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fthird_party%2FPluma%2FPluginManager.cpp;h=491a1a9f5a9b653b3f939573f01d24f92f1834cf;hb=45c0f8d631a76ca7af8452c99ed90f18b432f92a;hp=9579da2f2fe4ff59f408e2757adb9e5b5aea03a3;hpb=351f2e4ce6e3b11e77ba27998d41ff4310b806ad;p=cpPlugins.git diff --git a/lib/third_party/Pluma/PluginManager.cpp b/lib/third_party/Pluma/PluginManager.cpp index 9579da2..491a1a9 100644 --- a/lib/third_party/Pluma/PluginManager.cpp +++ b/lib/third_party/Pluma/PluginManager.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace pluma{ @@ -56,16 +57,26 @@ bool PluginManager::load(const std::string& path){ registerFunction = reinterpret_cast(lib->getSymbol("connect")); if(!registerFunction){ - fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str()); + //fprintf(stderr, "Failed to initialize plugin \"%s\": connect function not found\n", plugName.c_str()); delete lib; + throw std::runtime_error( + std::string( "Failed to initialize plugin \"" ) + + plugName + + std::string( "\": connect function not found" ) + ); return false; } // try to initialize plugin: if (!registerFunction(host)){ // plugin decided to fail - fprintf(stderr, "Self registry failed on plugin \"%s\".\n", plugName.c_str()); + // fprintf(stderr, "Self registry failed on plugin \"%s\".\n", plugName.c_str()); host.cancelAddictions(); delete lib; + throw std::runtime_error( + std::string( "Self registry failed on plugin \"" ) + + plugName + + std::string( "\"" ) + ); return false; } // Store the library if addictions are confirmed @@ -73,8 +84,13 @@ bool PluginManager::load(const std::string& path){ libraries[plugName] = lib; else{ // otherwise nothing was registered - fprintf(stderr, "Nothing registered by plugin \"%s\".\n", plugName.c_str()); + // fprintf(stderr, "Nothing registered by plugin \"%s\".\n", plugName.c_str()); delete lib; + throw std::runtime_error( + std::string( "Nothing registered by plugin \"" ) + + plugName + + std::string( "\"." ) + ); return false; } return true; @@ -166,7 +182,8 @@ void PluginManager::registerType(const std::string& type, unsigned int version, //////////////////////////////////////////////////////////// bool PluginManager::addProvider(Provider* provider){ if (provider == NULL){ - fprintf(stderr, "Trying to add null provider\n"); + // fprintf(stderr, "Trying to add null provider\n"); + throw std::runtime_error( "Trying to add null provider." ); return false; } return host.registerProvider(provider);