More verbose error reporting in PluginManager

This commit is contained in:
michael starke
2015-12-16 12:53:18 +01:00
parent 0074b369a4
commit 3165ad78b1

View File

@@ -92,23 +92,34 @@ NSString *const MPPluginManagerPluginBundleIdentifiyerKey = @"MPPluginManagerPlu
NSBundle *pluginBundle = [NSBundle bundleWithURL:pluginURL]; NSBundle *pluginBundle = [NSBundle bundleWithURL:pluginURL];
if(!pluginBundle) { if(!pluginBundle) {
NSLog(@"Could not create bundle %@", pluginURL.path);
continue; continue;
} }
NSError *error; NSError *error;
if(![pluginBundle preflightAndReturnError:&error]) { if(![pluginBundle preflightAndReturnError:&error]) {
NSLog(@"%@", error.localizedDescription ); NSLog(@"Preflight Error %@ %@", error.localizedDescription, error.localizedFailureReason );
continue; continue;
}; };
if(![pluginBundle loadAndReturnError:&error]) {
NSLog(@"Bunlde Loading Error %@ %@", error.localizedDescription, error.localizedFailureReason);
continue;
}
if(![self _validateClass:pluginBundle.principalClass]) { if(![self _validateClass:pluginBundle.principalClass]) {
NSLog(@"Wrong principal Class.");
continue; continue;
} }
MPPlugin *plugin = [[pluginBundle.principalClass alloc] initWithPluginManager:self]; MPPlugin *plugin = [[pluginBundle.principalClass alloc] initWithPluginManager:self];
if(plugin) { if(plugin) {
NSLog(@"Loaded plugin instance %@", pluginBundle.principalClass);
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerWillLoadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }]; [[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerWillLoadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }];
[self.mutablePlugins addObject:plugin]; [self.mutablePlugins addObject:plugin];
[[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerDidLoadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }]; [[NSNotificationCenter defaultCenter] postNotificationName:MPPluginManagerDidLoadPlugin object:self userInfo:@{ MPPluginManagerPluginBundleIdentifiyerKey : plugin.identifier }];
} }
else {
NSLog(@"Unable to instanciate instance of plugin class %@", pluginBundle.principalClass);
}
} }
} }