@@ -27,11 +27,11 @@ #import "OFPlugin.h" #import "OFString.h" #import "OFLocalization.h" #import "OFInitializationFailedException.h" -#import "OFOpenItemFailedException.h" +#import "OFLoadPluginFailedException.h" typedef OFPlugin *(*init_plugin_t)(void); of_plugin_handle_t of_dlopen(OFString *path, int flags) @@ -64,10 +64,21 @@ dlclose(handle); #else FreeLibrary(handle); #endif } + +OFString * +of_dlerror(void) +{ +#ifndef OF_WINDOWS + return [OFString stringWithCString: dlerror() + encoding: [OFLocalization encoding]]; +#else + return nil; +#endif +} @implementation OFPlugin + (id)pluginFromFile: (OFString *)path { void *pool = objc_autoreleasePoolPush(); @@ -84,13 +95,13 @@ #else path = [path stringByAppendingString: @PLUGIN_SUFFIX]; #endif if ((handle = of_dlopen(path, OF_RTLD_LAZY)) == NULL) - @throw [OFOpenItemFailedException exceptionWithPath: path - mode: nil - errNo: 0]; + @throw [OFLoadPluginFailedException + exceptionWithPath: path + error: of_dlerror()]; objc_autoreleasePoolPop(pool); initPlugin = (init_plugin_t)(uintptr_t)of_dlsym(handle, "init_plugin"); if (initPlugin == (init_plugin_t)0 || (plugin = initPlugin()) == nil) {