/pidgin/main: 956f247148db: More error logging, please.

Mark Doliner mark at kingant.net
Tue Jan 28 10:38:13 EST 2014


Changeset: 956f247148dbef7476cd98d08cd9a2fb0aba0e1d
Author:	 Mark Doliner <mark at kingant.net>
Date:	 2014-01-18 16:30 -0800
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/956f247148db

Description:

More error logging, please.

diffstat:

 libpurple/protocols/yahoo/util.c |  42 ++++++++++++++++++++++++++++++---------
 1 files changed, 32 insertions(+), 10 deletions(-)

diffs (75 lines):

diff --git a/libpurple/protocols/yahoo/util.c b/libpurple/protocols/yahoo/util.c
--- a/libpurple/protocols/yahoo/util.c
+++ b/libpurple/protocols/yahoo/util.c
@@ -132,6 +132,7 @@ char *yahoo_string_encode(PurpleConnecti
 	YahooData *yd = gc->proto_data;
 	char *ret;
 	const char *to_codeset;
+	GError *error = NULL;
 
 	if (yd->jp)
 		return g_strdup(str);
@@ -140,12 +141,22 @@ char *yahoo_string_encode(PurpleConnecti
 		return g_strdup(str);
 
 	to_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset",  "ISO-8859-1");
-	ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, NULL);
+	ret = g_convert_with_fallback(str, -1, to_codeset, "UTF-8", "?", NULL, NULL, &error);
+	if (!ret) {
+		if (error) {
+			purple_debug_error("yahoo", "Could not convert %s from UTF-8 to "
+					"%s: %d - %s\n", str ? str : "(null)", to_codeset,
+					error->code,
+					error->message ? error->message : "(null)");
+			g_error_free(error);
+		} else {
+			purple_debug_error("yahoo", "Could not convert %s from UTF-8 to "
+					"%s: unkown error\n", str ? str : "(null)", to_codeset);
+		}
+		return g_strdup("");
+	}
 
-	if (ret)
-		return ret;
-	else
-		return g_strdup("");
+	return ret;
 }
 
 /**
@@ -161,6 +172,7 @@ char *yahoo_string_decode(PurpleConnecti
 	YahooData *yd = gc->proto_data;
 	char *ret;
 	const char *from_codeset;
+	GError *error = NULL;
 
 	if (utf8) {
 		if (g_utf8_validate(str, -1, NULL))
@@ -174,12 +186,22 @@ char *yahoo_string_decode(PurpleConnecti
 	else
 		from_codeset = purple_account_get_string(purple_connection_get_account(gc), "local_charset",  "ISO-8859-1");
 
-	ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
+	ret = g_convert_with_fallback(str, -1, "UTF-8", from_codeset, NULL, NULL, NULL, &error);
+	if (!ret) {
+		if (error) {
+			purple_debug_error("yahoo", "Could not convert %s from %s to "
+					"UTF-8: %d - %s\n", str ? str : "(null)", from_codeset,
+					error->code, error->message ? error->message : "(null)");
+			g_error_free(error);
+		} else {
+			purple_debug_error("yahoo", "Could not convert %s from %s to "
+					"UTF-8: unkown error\n", str ? str : "(null)",
+					from_codeset);
+		}
+		return g_strdup("");
+	}
 
-	if (ret)
-		return ret;
-	else
-		return g_strdup("");
+	return ret;
 }
 
 char *yahoo_convert_to_numeric(const char *str)



More information about the Commits mailing list