changeset 23620:57419367b18d

Add error handling for visiblity to why Perl plugins fail to load. Fixes #240
author Daniel Atallah <daniel.atallah@gmail.com>
date Wed, 30 Jul 2008 04:51:58 +0000
parents ece34c9599f5
children c31012d6f708
files libpurple/plugins/perl/perl.c
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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);