[couchdb-glib] Don't force callers to pass a GError



commit 64f510f68a4528d4aaf5e35e8c399bce605939c7
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Tue Feb 9 11:14:33 2010 +0100

    Don't force callers to pass a GError

 couchdb-glib/couchdb-session.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/couchdb-glib/couchdb-session.c b/couchdb-glib/couchdb-session.c
index 48aebeb..c073b27 100644
--- a/couchdb-glib/couchdb-session.c
+++ b/couchdb-glib/couchdb-session.c
@@ -684,11 +684,16 @@ couchdb_session_send_message (CouchdbSession *couchdb, const char *method, const
 {
 	SoupMessage *http_message;
 	guint status;
+	GError *real_error;
 	
 	g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), FALSE);
 	g_return_val_if_fail (method != NULL, FALSE);
-	g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-	
+
+	if (error != NULL)
+		real_error = *error;
+	else
+		real_error = NULL;
+
 	http_message = soup_message_new (method, url);
 	if (body != NULL) {
 		soup_message_set_request (http_message, "application/json", SOUP_MEMORY_COPY,
@@ -714,10 +719,11 @@ couchdb_session_send_message (CouchdbSession *couchdb, const char *method, const
 	status = soup_session_send_message (couchdb->priv->http_session, http_message);
 	if (SOUP_STATUS_IS_SUCCESSFUL (status)) {
 		if (parser != NULL)
-		       	parse_json_response (couchdb, parser, http_message, error);
+		       	parse_json_response (couchdb, parser, http_message, real_error);
 	       	return TRUE;
 	} else {
-		g_set_error (error, COUCHDB_ERROR, status, "%s", http_message->reason_phrase);
+		if (error != NULL)
+			g_set_error (error, COUCHDB_ERROR, status, "%s", http_message->reason_phrase);
 		return FALSE;
 	}
 }



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