[evolution-data-server] Better runtime warnings in tcp_stream_set_error_from_pr_error().



commit 5dd95d2afc68263e1c76f04d6049fb7be83d60bf
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Nov 29 00:20:07 2011 -0600

    Better runtime warnings in tcp_stream_set_error_from_pr_error().
    
    I keep seeing some kind of NSPR error which apparently has no error text
    (PR_GetErrorTextLength() returns 0).  This should at least help pin down
    the error code so maybe we can special-case it.

 camel/camel-tcp-stream-raw.c |   29 ++++++++++++++++++++---------
 1 files changed, 20 insertions(+), 9 deletions(-)
---
diff --git a/camel/camel-tcp-stream-raw.c b/camel/camel-tcp-stream-raw.c
index 8630070..af6d674 100644
--- a/camel/camel-tcp-stream-raw.c
+++ b/camel/camel-tcp-stream-raw.c
@@ -276,21 +276,32 @@ _set_g_error_from_errno (GError **error,
 static void
 tcp_stream_set_error_from_pr_error (GError **error)
 {
-	gchar *error_message;
+	gchar *error_message = NULL;
 	PRInt32 length;
 
 	length = PR_GetErrorTextLength ();
-	g_return_if_fail (length > 0);
-
-	error_message = g_malloc0 (length + 1);
-	PR_GetErrorText (error_message);
+	if (length > 0) {
+		error_message = g_malloc0 (length + 1);
+		PR_GetErrorText (error_message);
+	} else {
+		g_warning (
+			"NSPR error code %d has no text",
+			PR_GetError ());
+	}
 
 	_set_errno_from_pr_error (PR_GetError ());
 
-	g_set_error_literal (
-		error, G_IO_ERROR,
-		g_io_error_from_errno (errno),
-		error_message);
+	if (error_message != NULL)
+		g_set_error_literal (
+			error, G_IO_ERROR,
+			g_io_error_from_errno (errno),
+			error_message);
+	else
+		g_set_error (
+			error, G_IO_ERROR,
+			g_io_error_from_errno (errno),
+			_("NSPR error code %d"),
+			PR_GetError ());
 
 	g_free (error_message);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]