[libgrss] Little improvements on error reporting
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgrss] Little improvements on error reporting
- Date: Tue, 6 Mar 2012 21:53:00 +0000 (UTC)
commit e8f625ad75d723d49870d5123d9c1a982fda64b9
Author: Roberto Guido <bob4job gmail com>
Date: Tue Mar 6 22:49:49 2012 +0100
Little improvements on error reporting
NEWS | 14 ++++++++------
README | 7 ++++---
configure.ac | 6 +++---
src/feeds-group.c | 18 +++++++++++++-----
src/feeds-pool.c | 13 ++++++-------
src/utils.c | 15 +++++++--------
6 files changed, 41 insertions(+), 32 deletions(-)
---
diff --git a/NEWS b/NEWS
index 6e386a4..14e553b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,12 @@
-libgrss 0.5 (UNRELEASED)
+libgrss 0.5
==============================================================================
- Complete API break: all object and function names moved to "grss" namespace
-- Added XOXO and XBEL files parsers
-- Added FeedsPublisher to expose feeds contents as files or by local server
-- PubSubHub and RSSCloud subscribers
-- Added functions feed_channel_fetch_async() and feed_channel_new_from_file()
+- Added GrssFeedsPublisher to expose feeds contents as files or by local server
+- Added GrssFeedsSubscriber to subscribe PubSubHubBub and RSSCloud services
+- Added support for XOXO and XBEL in GrssFeedsGroups
+- Improved error reporting
+- More asyncronous utility functions to fetch contents
+- Bugfixes
libgrss 0.4
==============================================================================
@@ -31,4 +33,4 @@ libgrss 0.2
libgrss 0.1
===============================================================================
-- First release, including abstraction for feed channel, item, enclosure, and a feeds auto-fetcher.
+- First release, including abstraction for feed channel, item, enclosure, and a feeds auto-fetcher
diff --git a/README b/README
index 4937118..4e46834 100644
--- a/README
+++ b/README
@@ -8,8 +8,9 @@ REQUIREMENTS
-------------------------------------------------------------------------------
libgrss depends on:
- - libxml2 >= 2.7.4
- - libsoup-2.4 >= 2.28.1
+ - libglib2 >= 2.30.2
+ - libxml2 >= 2.7.8
+ - libsoup-2.4 >= 2.36.1
INSTALLATION
-------------------------------------------------------------------------------
@@ -20,4 +21,4 @@ COPYRIGHT AND LICENSING
libgrss is released under the terms of the GNU Lesser General Public License,
version 3 or, at your option, any later version.
-libgrss is Copyright (C) 2009/2010 Roberto Guido, Michele Tameni.
+libgrss is Copyright (C) 2009/2012 Roberto Guido, Michele Tameni.
diff --git a/configure.ac b/configure.ac
index dfd4e61..61effa3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,9 +15,9 @@ m4_define([lt_revision], [libgrss_interface_age])
m4_define([lt_age],
[m4_eval(libgrss_binary_age - libgrss_interface_age)])
-m4_define([glib_req_version], [2.22.2])
-m4_define([xml_req_version], [2.7.4])
-m4_define([soup_req_version], [2.28.1])
+m4_define([glib_req_version], [2.30.2])
+m4_define([xml_req_version], [2.7.8])
+m4_define([soup_req_version], [2.36.1])
AC_PREREQ([2.59])
AC_INIT([libgrss], [libgrss_version], [], [libgrss])
diff --git a/src/feeds-group.c b/src/feeds-group.c
index faa19bf..12eadf8 100644
--- a/src/feeds-group.c
+++ b/src/feeds-group.c
@@ -130,7 +130,6 @@ retrieve_group_handler (GrssFeedsGroup *group, xmlDocPtr doc, xmlNodePtr cur)
iter = g_slist_next (iter);
}
- g_warning ("No suitable parser has been found.");
return NULL;
}
@@ -186,16 +185,23 @@ grss_feeds_group_parse_file (GrssFeedsGroup *group, const gchar *path, GError **
do {
doc = file_to_xml (path);
- g_set_error (error, FEEDS_GROUP_ERROR, FEEDS_GROUP_PARSE_ERROR, "Empty document");
+ if (doc == NULL) {
+ g_set_error (error, FEEDS_GROUP_ERROR, FEEDS_GROUP_PARSE_ERROR, "Empty document");
+ break;
+ }
- if ((cur = xmlDocGetRootElement (doc)) == NULL)
+ if ((cur = xmlDocGetRootElement (doc)) == NULL) {
+ g_set_error (error, FEEDS_GROUP_ERROR, FEEDS_GROUP_PARSE_ERROR, "Empty document");
break;
+ }
while (cur && xmlIsBlankNode (cur))
cur = cur->next;
- if (!cur)
+ if (!cur) {
+ g_set_error (error, FEEDS_GROUP_ERROR, FEEDS_GROUP_PARSE_ERROR, "Empty document");
break;
+ }
if (!cur->name) {
g_set_error (error, FEEDS_GROUP_ERROR, FEEDS_GROUP_PARSE_ERROR, "Invalid XML");
@@ -203,8 +209,10 @@ grss_feeds_group_parse_file (GrssFeedsGroup *group, const gchar *path, GError **
}
handler = retrieve_group_handler (group, doc, cur);
- if (handler == NULL)
+ if (handler == NULL) {
+ g_set_error (error, FEEDS_GROUP_ERROR, FEEDS_GROUP_PARSE_ERROR, "Unrecognized format");
break;
+ }
items = grss_feeds_group_handler_parse (handler, doc, error);
diff --git a/src/feeds-pool.c b/src/feeds-pool.c
index 14ce06e..1789acc 100644
--- a/src/feeds-pool.c
+++ b/src/feeds-pool.c
@@ -261,7 +261,6 @@ static void
feed_downloaded (GObject *source, GAsyncResult *res, gpointer user_data)
{
GList *items;
- GError *error;
GrssFeedChannelWrap *feed;
feed = (GrssFeedChannelWrap*) user_data;
@@ -269,14 +268,14 @@ feed_downloaded (GObject *source, GAsyncResult *res, gpointer user_data)
return;
error = NULL;
- items = grss_feed_channel_fetch_all_finish (GRSS_FEED_CHANNEL (source), res, &error);
+ items = grss_feed_channel_fetch_all_finish (GRSS_FEED_CHANNEL (source), res, NULL);
- if (items == NULL && error) {
- g_warning ("Unable to parse feed at %s: %s", grss_feed_channel_get_source (feed->channel), error->message);
- g_error_free (error);
- }
+ /*
+ TODO Emit specific signal also when operation fails
+ */
- g_signal_emit (feed->pool, signals [FEED_READY], 0, feed->channel, items, NULL);
+ if (items != NULL)
+ g_signal_emit (feed->pool, signals [FEED_READY], 0, feed->channel, items, NULL);
feed->next_fetch = time (NULL) + (grss_feed_channel_get_update_interval (feed->channel) * 60);
}
diff --git a/src/utils.c b/src/utils.c
index 1c13793..6bf66c6 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -565,6 +565,11 @@ date_to_ISO8601 (time_t date)
Copyright (C) 2000-2003 Andrew Lanoix
Copyright (C) 2007 Tim-Philipp MÃller <tim centricular net>
*/
+
+/*
+ TODO This function needs better error reporting
+*/
+
GInetAddress*
detect_internet_address ()
{
@@ -589,13 +594,10 @@ detect_internet_address ()
return NULL;
sockfd = socket (AF_INET, SOCK_DGRAM, 0);
- if (!sockfd) {
- g_warning ("Unable to open a socket to detect interface exposed to Internet");
+ if (!sockfd)
return NULL;
- }
if (connect (sockfd, (struct sockaddr*) &serv_add, sizeof (serv_add)) == -1) {
- g_warning ("Unable to open a connection to detect interface exposed to Internet");
close (sockfd);
return NULL;
}
@@ -603,17 +605,14 @@ detect_internet_address ()
len = sizeof (myaddr);
if (getsockname (sockfd, (struct sockaddr*) &myaddr, &len) != 0) {
close (sockfd);
- g_warning ("Unable to obtain information about interface exposed to Internet");
return NULL;
}
close (sockfd);
memset (ip, 0, sizeof (char) * 100);
- if (inet_ntop (AF_INET, &(((struct sockaddr_in*) &myaddr)->sin_addr), ip, 100) == NULL) {
- g_warning ("Unable to obtain IP exposed to Internet");
+ if (inet_ntop (AF_INET, &(((struct sockaddr_in*) &myaddr)->sin_addr), ip, 100) == NULL)
return NULL;
- }
return g_inet_address_new_from_string (ip);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]