# HG changeset patch # User Daniel Atallah # Date 1217393518 0 # Node ID 57419367b18d0395d96fe0a7accc7637ff3da754 # Parent ece34c9599f5413cfc0b922c15a5aff5372a9ef7 Add error handling for visiblity to why Perl plugins fail to load. Fixes #240 diff -r ece34c9599f5 -r 57419367b18d libpurple/plugins/perl/perl.c --- a/libpurple/plugins/perl/perl.c Wed Jul 30 03:58:21 2008 +0000 +++ b/libpurple/plugins/perl/perl.c Wed Jul 30 04:51:58 2008 +0000 @@ -251,7 +251,7 @@ char *args[] = {"", plugin->path }; char **argv = args; - int argc = 2; + int argc = 2, ret; PerlInterpreter *prober; gboolean status = TRUE; HV *plugin_info; @@ -285,9 +285,29 @@ } #endif - perl_parse(prober, xs_init, argc, argv, NULL); + ret = perl_parse(prober, xs_init, argc, argv, NULL); + + if (ret != 0) { + STRLEN len; + const char * errmsg = "Unknown error"; + if (SvTRUE(ERRSV)) + errmsg = SvPV(ERRSV, len); + purple_debug_error("perl", "Unable to parse plugin %s (%d:%s)\n", + plugin->path, ret, errmsg); + goto cleanup; + } - perl_run(prober); + ret = perl_run(prober); + + if (ret != 0) { + STRLEN len; + const char * errmsg = "Unknown error"; + if (SvTRUE(ERRSV)) + errmsg = SvPV(ERRSV, len); + purple_debug_error("perl", "Unable to run perl interpreter on plugin %s (%d:%s)\n", + plugin->path, ret, errmsg); + goto cleanup; + } plugin_info = perl_get_hv("PLUGIN_INFO", FALSE); @@ -435,6 +455,7 @@ } } + cleanup: PL_perl_destruct_level = 1; PERL_SET_CONTEXT(prober); perl_destruct(prober);