[evolution-data-server] Bug #631842 - Improve error reporting in some ECal/EBook functions
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #631842 - Improve error reporting in some ECal/EBook functions
- Date: Fri, 29 Oct 2010 09:30:53 +0000 (UTC)
commit f56727c4791bd078356b544a9e6316fdfd26184f
Author: Christophe Fergeau <teuf gnome org>
Date: Fri Oct 29 11:30:03 2010 +0200
Bug #631842 - Improve error reporting in some ECal/EBook functions
addressbook/libebook/e-book.c | 7 ++++++-
calendar/libecal/e-cal.c | 33 +++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/addressbook/libebook/e-book.c b/addressbook/libebook/e-book.c
index 77fa771..291d2bc 100644
--- a/addressbook/libebook/e-book.c
+++ b/addressbook/libebook/e-book.c
@@ -3349,7 +3349,12 @@ e_book_new_default_addressbook (GError **error)
return NULL;
source = e_source_list_peek_default_source (source_list);
- g_return_val_if_fail (source != NULL, NULL);
+ if (!source) {
+ g_set_error_literal (error, E_BOOK_ERROR, E_BOOK_ERROR_NO_SUCH_BOOK,
+ _("Address book does not exist"));
+ g_object_unref (source_list);
+ return NULL;
+ }
book = e_book_new (source, error);
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index 32427e2..2890008 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -4131,15 +4131,28 @@ e_cal_open_default (ECal **ecal,
return FALSE;
source = e_source_list_peek_default_source (source_list);
- g_return_val_if_fail (source != NULL, FALSE);
+ if (!source) {
+ g_set_error_literal (error, E_CALENDAR_ERROR,
+ E_CALENDAR_STATUS_NO_SUCH_CALENDAR,
+ e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
+ g_object_unref (source_list);
+ return FALSE;
+ }
/* XXX This can fail but doesn't take a GError!? */
client = e_cal_new (source, type);
- g_return_val_if_fail (client != NULL, FALSE);
+ if (!client) {
+ g_set_error_literal (error, E_CALENDAR_ERROR,
+ E_CALENDAR_STATUS_OTHER_ERROR,
+ e_cal_get_error_message (E_CALENDAR_STATUS_OTHER_ERROR));
+ g_object_unref (source_list);
+ return FALSE;
+ }
e_cal_set_auth_func (client, func, data);
if (!e_cal_open (client, TRUE, error)) {
g_object_unref (client);
+ g_object_unref (source_list);
return FALSE;
}
@@ -4168,7 +4181,9 @@ e_cal_set_default (ECal *ecal, GError **error)
source = e_cal_get_source (ecal);
if (!source) {
- /* XXX gerror */
+ g_set_error_literal (error, E_CALENDAR_ERROR,
+ E_CALENDAR_STATUS_NO_SUCH_CALENDAR,
+ e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
return FALSE;
}
@@ -4188,7 +4203,9 @@ set_default_source (ESourceList *sources, ESource *source, GError **error)
it's not we don't bother adding it, just return an error */
source = e_source_list_peek_source_by_uid (sources, uid);
if (!source) {
- /* XXX gerror */
+ g_set_error_literal (error, E_CALENDAR_ERROR,
+ E_CALENDAR_STATUS_NO_SUCH_CALENDAR,
+ e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
g_object_unref (sources);
return FALSE;
}
@@ -4276,10 +4293,14 @@ e_cal_get_sources (ESourceList **sources, ECalSourceType type, GError **error)
return get_sources (sources, "/apps/evolution/memos/sources", error);
break;
default:
- /* FIXME Fill in error */
+ g_set_error_literal (error, E_CALENDAR_ERROR,
+ E_CALENDAR_STATUS_NO_SUCH_CALENDAR,
+ e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
return FALSE;
}
- /* FIXME Fill in error */
+ g_set_error_literal (error, E_CALENDAR_ERROR,
+ E_CALENDAR_STATUS_NO_SUCH_CALENDAR,
+ e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]