error reporting in calendar publishing

"David Trowbridge" <[email protected]>
Newsgroups gmane.comp.gnome.evolution.patches
Message-ID <[email protected]>
Just wrapping up a few loose ends.

-D

_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches
errors.diff (text/x-patch, 8.9 KB)
? errors.diff
? evolution-zip
? iconv-detect.h
? addressbook/addressbook.error
? calendar/calendar.error
? calendar/conduits/memo/Makefile
? calendar/conduits/memo/Makefile.in
? calendar/gui/apps_evolution_calendar-2.6.schemas
? composer/mail-composer.error
? devel-docs/misc/.errors.txt.swp
? e-util/.e-error.h.swp
? e-util/e-system.error
? filter/filter.error
? help/C/evolution-2.6-C.omf
? help/C/evolution-2.6.xml
? mail/mail.error
? mail/default/fr/Makefile
? mail/default/fr/Makefile.in
? mail/default/lt/Makefile
? mail/default/lt/Makefile.in
? plugins/addressbook-file/org-gnome-addressbook-file.eplug
? plugins/default-mailer/org-gnome-default-mailer.eplug
? plugins/default-mailer/org-gnome-default-mailer.error
? plugins/default-source/org-gnome-default-source.eplug
? plugins/exchange-operations/org-gnome-exchange-operations.eplug
? plugins/exchange-operations/org-gnome-exchange-operations.error
? plugins/itip-formatter/org-gnome-itip-formatter.error
? plugins/mailing-list-actions/org-gnome-mailing-list-actions.error
? plugins/publish-calendar/org-gnome-publish-calendar.error
? po/stamp-it
? shell/shell.error
? views/memos/Makefile
? views/memos/Makefile.in
? win32/Makefile
? win32/Makefile.in
Index: plugins/publish-calendar/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- plugins/publish-calendar/Makefile.am	4 Jan 2006 02:34:45 -0000	1.5
+++ plugins/publish-calendar/Makefile.am	22 Mar 2006 08:49:36 -0000
@@ -11,6 +11,9 @@
 	publish-calendar.glade
 plugin_LTLIBRARIES = liborg-gnome-publish-calendar.la
 
+error_DATA = org-gnome-publish-calendar.error
+errordir = $(privdatadir)/errors
+
 liborg_gnome_publish_calendar_la_SOURCES =	\
 	publish-calendar.c			\
 	publish-format-fb.c			\
@@ -31,5 +34,6 @@
 
 EXTRA_DIST =					\
 	org-gnome-publish-calendar.eplug.xml	\
+	org-gnome-publish-calendar.error.xml	\
 	publish-calendar.glade			\
 	org-gnome-publish-calendar.xml
Index: plugins/publish-calendar/org-gnome-publish-calendar.error.xml
===================================================================
RCS file: plugins/publish-calendar/org-gnome-publish-calendar.error.xml
diff -N plugins/publish-calendar/org-gnome-publish-calendar.error.xml
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/publish-calendar/org-gnome-publish-calendar.error.xml	22 Mar 2006 08:49:36 -0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<error-list domain="org-gnome-publish-calendar">
+
+  <error id="create-uri-error" type="error">
+    <_primary>Couldn't create uri {0}.</_primary>
+  </error>
+
+  <error id="vfs-open-error" type="error">
+    <_primary>Unable to open {0}.</_primary>
+    <_secondary>{1}</_secondary>
+  </error>
+
+  <error id="vfs-write-error" type="error">
+    <_primary>Write error while publishing calendar.</_primary>
+    <_secondary>{0}</_secondary>
+  </error>
+
+</error-list>
Index: plugins/publish-calendar/publish-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/publish-calendar.c,v
retrieving revision 1.4
diff -u -r1.4 publish-calendar.c
--- plugins/publish-calendar/publish-calendar.c	3 Mar 2006 13:46:52 -0000	1.4
+++ plugins/publish-calendar/publish-calendar.c	22 Mar 2006 08:49:37 -0000
@@ -31,6 +31,8 @@
 #include <calendar/gui/e-cal-menu.h>
 #include <shell/es-event.h>
 #include <e-util/e-util-private.h>
+#include <e-util/e-error.h>
+#include "publish-calendar.h"
 #include "url-editor-dialog.h"
 #include "publish-format-fb.h"
 #include "publish-format-ical.h"
@@ -83,16 +85,14 @@
 		gnome_vfs_uri_set_password (vfs_uri, password);
 
 		if (vfs_uri == NULL) {
-			fprintf (stderr, "Couldn't create uri %s\n", uri->location);
-			/* FIXME: EError */
+			e_error_run (NULL, ERROR_DOMAIN "create-uri-error", uri->location, NULL);
 			g_free (password);
 			return;
 		}
 
 		result = gnome_vfs_create_uri (&handle, vfs_uri, GNOME_VFS_OPEN_WRITE, FALSE, 0666);
 		if (result != GNOME_VFS_OK) {
-			/* FIXME: EError */
-			fprintf (stderr, "Couldn't open %s: %s\n", uri->location, gnome_vfs_result_to_string (result));
+			e_error_run (NULL, ERROR_DOMAIN "vfs-open-error", uri->location, gnome_vfs_result_to_string (result), NULL);
 			g_free (password);
 			return;
 		}
Index: plugins/publish-calendar/publish-calendar.h
===================================================================
RCS file: plugins/publish-calendar/publish-calendar.h
diff -N plugins/publish-calendar/publish-calendar.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/publish-calendar/publish-calendar.h	22 Mar 2006 08:49:37 -0000
@@ -0,0 +1,27 @@
+/*
+ * Authors: David Trowbridge <[email protected]>
+ *
+ * Copyright (C) 2006 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ */
+
+#ifndef PUBLISH_CALENDAR_H
+#define PUBLISH_CALENDAR_H
+
+#define ERROR_DOMAIN "org-gnome-publish-calendar"
+
+#endif
Index: plugins/publish-calendar/publish-format-fb.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/publish-format-fb.c,v
retrieving revision 1.2
diff -u -r1.2 publish-format-fb.c
--- plugins/publish-calendar/publish-format-fb.c	27 Jan 2006 16:34:02 -0000	1.2
+++ plugins/publish-calendar/publish-format-fb.c	22 Mar 2006 08:49:37 -0000
@@ -28,7 +28,9 @@
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-util.h>
 #include <libecal/e-cal-time-util.h>
+#include <e-util/e-error.h>
 #include <calendar/common/authentication.h>
+#include "publish-calendar.h"
 #include "publish-format-fb.h"
 
 static gboolean
@@ -36,11 +38,11 @@
 {
 	ESource *source;
 	ECal *client = NULL;
-	GError *error = NULL;
 	GList *objects;
 	icaltimezone *utc;
 	time_t start = time(NULL), end;
 	icalcomponent *top_level;
+	GError *error;
 
 	utc = icaltimezone_get_utc_timezone ();
 	start = time_day_begin_with_zone (start, utc);
@@ -55,16 +57,15 @@
 	}
 
 	if (!e_cal_open (client, TRUE, &error)) {
-		/* FIXME: EError */
+		g_warning ("Could not open the calendar %s \n", error->message);
 		g_object_unref (client);
 		g_error_free (error);
 		return FALSE;
 	}
 
 	top_level = e_cal_util_new_top_level ();
-	error = NULL;
 
-	if (e_cal_get_free_busy (client, NULL, start, end, &objects, &error)) {
+	if (e_cal_get_free_busy (client, NULL, start, end, &objects, NULL)) {
 		char *ical_string;
 		GnomeVFSFileSize bytes_written;
 		GnomeVFSResult result;
@@ -78,14 +79,12 @@
 
 		ical_string = icalcomponent_as_ical_string (top_level);
 		if ((result = gnome_vfs_write (handle, (gconstpointer) ical_string, strlen (ical_string), &bytes_written)) != GNOME_VFS_OK) {
-			/* FIXME: EError */
+			e_error_run (NULL, ERROR_DOMAIN "vfs-write-error", gnome_vfs_result_to_string (result), NULL);
 			gnome_vfs_close (handle);
 			return FALSE;
 		}
 	} else {
-		/* FIXME: EError */
 		g_object_unref (client);
-		g_error_free (error);
 		return FALSE;
 	}
 
Index: plugins/publish-calendar/publish-format-ical.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/publish-calendar/publish-format-ical.c,v
retrieving revision 1.1
diff -u -r1.1 publish-format-ical.c
--- plugins/publish-calendar/publish-format-ical.c	19 Dec 2005 10:08:10 -0000	1.1
+++ plugins/publish-calendar/publish-format-ical.c	22 Mar 2006 08:49:37 -0000
@@ -26,7 +26,9 @@
 #include <libedataserver/e-source-list.h>
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-util.h>
+#include <e-util/e-error.h>
 #include <calendar/common/authentication.h>
+#include "publish-calendar.h"
 #include "publish-format-ical.h"
 
 static gboolean
@@ -47,7 +49,7 @@
 	}
 
 	if (!e_cal_open (client, TRUE, &error)) {
-		/* FIXME: EError */
+		g_warning("Could not open the calendar %s \n", error->message);
 		g_object_unref (client);
 		g_error_free (error);
 		return FALSE;
@@ -69,12 +71,11 @@
 
 		ical_string = icalcomponent_as_ical_string (top_level);
 		if ((result = gnome_vfs_write (handle, (gconstpointer) ical_string, strlen (ical_string), &bytes_written)) != GNOME_VFS_OK) {
-			/* FIXME: EError */
+			e_error_run (NULL, ERROR_DOMAIN "vfs-write-error", gnome_vfs_result_to_string (result), NULL);
 			gnome_vfs_close (handle);
 			return FALSE;
 		}
 	} else {
-		/* FIXME: EError */
 		g_object_unref (client);
 		g_error_free (error);
 		return FALSE;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.