[yelp/yelp-3-0] [libyelp] More error handling for Mallard documents
- From: Shaun McCance <shaunm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [yelp/yelp-3-0] [libyelp] More error handling for Mallard documents
- Date: Sun, 15 Nov 2009 22:36:56 +0000 (UTC)
commit aebb9fcc09759c91a5514630132014cf49af01dd
Author: Shaun McCance <shaunm gnome org>
Date: Sun Oct 25 20:04:47 2009 -0500
[libyelp] More error handling for Mallard documents
libyelp/Makefile.am | 1 +
libyelp/yelp-document.c | 12 +++++++---
libyelp/yelp-document.h | 4 +-
libyelp/yelp-error.c | 43 +++++++++++++++++++++++++++++++++++++++
libyelp/yelp-error.h | 8 +++++-
libyelp/yelp-mallard-document.c | 24 +++++++++++++++------
libyelp/yelp-transform.c | 1 +
libyelp/yelp-transform.h | 1 +
8 files changed, 79 insertions(+), 15 deletions(-)
---
diff --git a/libyelp/Makefile.am b/libyelp/Makefile.am
index c22d748..6ab86f1 100644
--- a/libyelp/Makefile.am
+++ b/libyelp/Makefile.am
@@ -2,6 +2,7 @@ lib_LTLIBRARIES = libyelp.la
libyelp_la_SOURCES = \
yelp-debug.c \
+ yelp-error.c \
yelp-document.c \
yelp-location-entry.c \
yelp-mallard-document.c \
diff --git a/libyelp/yelp-document.c b/libyelp/yelp-document.c
index 8190995..53ba5a2 100644
--- a/libyelp/yelp-document.c
+++ b/libyelp/yelp-document.c
@@ -29,6 +29,7 @@
#include "yelp-debug.h"
#include "yelp-document.h"
+#include "yelp-error.h"
#include "yelp-mallard-document.h"
#include "yelp-simple-document.h"
@@ -667,7 +668,7 @@ void
yelp_document_signal (YelpDocument *document,
const gchar *page_id,
YelpDocumentSignal signal,
- GError *error)
+ const GError *error)
{
GSList *reqs, *cur;
@@ -690,7 +691,10 @@ yelp_document_signal (YelpDocument *document,
g_idle_add ((GSourceFunc) request_idle_info, request);
break;
case YELP_DOCUMENT_SIGNAL_ERROR:
- /* FIXME */
+ request->idle_funcs++;
+ request->error = yelp_error_copy (error);
+ g_idle_add ((GSourceFunc) request_idle_error, request);
+ break;
default:
break;
}
@@ -701,7 +705,7 @@ yelp_document_signal (YelpDocument *document,
void
yelp_document_error_pending (YelpDocument *document,
- GError *error)
+ const GError *error)
{
YelpDocumentPriv *priv = GET_PRIV (document);
GSList *cur;
@@ -714,7 +718,7 @@ yelp_document_error_pending (YelpDocument *document,
if (priv->reqs_pending) {
for (cur = priv->reqs_pending; cur; cur = cur->next) {
request = cur->data;
- request->error = g_error_copy (error);
+ request->error = yelp_error_copy (error);
request->idle_funcs++;
g_idle_add ((GSourceFunc) request_idle_error, request);
}
diff --git a/libyelp/yelp-document.h b/libyelp/yelp-document.h
index 60e4c53..8a6feae 100644
--- a/libyelp/yelp-document.h
+++ b/libyelp/yelp-document.h
@@ -138,9 +138,9 @@ gboolean yelp_document_has_page (YelpDocument *document,
void yelp_document_signal (YelpDocument *document,
const gchar *page_id,
YelpDocumentSignal signal,
- GError *error);
+ const GError *error);
void yelp_document_error_pending (YelpDocument *document,
- GError *error);
+ const GError *error);
/* FIXME */
/*
void yelp_document_error_request (YelpDocument *document,
diff --git a/libyelp/yelp-error.c b/libyelp/yelp-error.c
new file mode 100644
index 0000000..8de0231
--- /dev/null
+++ b/libyelp/yelp-error.c
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2009 Shaun McCance <shaunm gnome org>
+ *
+ * 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.
+ *
+ * Author: Shaun McCance <shaunm gnome org>
+ */
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include "yelp-error.h"
+
+GError *
+yelp_error_copy (GError *error)
+{
+ if (error == NULL)
+ return g_error_new (YELP_ERROR, YELP_ERROR_UNKNOWN,
+ _("An unknown error occurred."));
+ else
+ return g_error_copy (error);
+}
+
+const gchar *
+yelp_error_get_title (GError *error)
+{
+ /* FIXME */
+ return NULL;
+}
diff --git a/libyelp/yelp-error.h b/libyelp/yelp-error.h
index 103f87e..3dcbf6e 100644
--- a/libyelp/yelp-error.h
+++ b/libyelp/yelp-error.h
@@ -23,7 +23,7 @@
#ifndef __YELP_ERROR_H__
#define __YELP_ERROR_H__
-#include <gtk/gtk.h>
+#include <glib.h>
G_BEGIN_DECLS
@@ -32,9 +32,13 @@ G_BEGIN_DECLS
typedef enum {
YELP_ERROR_NOT_FOUND,
YELP_ERROR_CANT_READ,
- YELP_ERROR_PROCESSING
+ YELP_ERROR_PROCESSING,
+ YELP_ERROR_UNKNOWN
} YelpError;
+GError * yelp_error_copy (GError *error);
+const gchar * yelp_error_get_title (GError *error);
+
G_END_DECLS
#endif /* __YELP_ERROR_H__ */
diff --git a/libyelp/yelp-mallard-document.c b/libyelp/yelp-mallard-document.c
index 3cf7feb..1381cfc 100644
--- a/libyelp/yelp-mallard-document.c
+++ b/libyelp/yelp-mallard-document.c
@@ -280,6 +280,7 @@ mallard_think (YelpMallardDocument *mallard)
_("The directory â??%sâ?? does not exist."),
search_path[0]);
yelp_document_error_pending ((YelpDocument *) document, error);
+ g_error_free (error);
goto done;
}
@@ -321,11 +322,8 @@ mallard_think (YelpMallardDocument *mallard)
g_mutex_lock (priv->mutex);
priv->state = MALLARD_STATE_IDLE;
while (priv->pending) {
- gchar *page_id, *real_id;
- page_id = (gchar *) priv->pending->data;
- real_id = yelp_document_get_page_id ((YelpDocument *) mallard, page_id);
- mallard_try_run (mallard, real_id);
- g_free (real_id);
+ gchar *page_id = (gchar *) priv->pending->data;
+ mallard_try_run (mallard, page_id);
g_free (page_id);
priv->pending = g_slist_delete_link (priv->pending, priv->pending);
}
@@ -345,10 +343,21 @@ mallard_try_run (YelpMallardDocument *mallard,
{
/* We expect to be in a locked mutex when this function is called. */
YelpMallardDocumentPrivate *priv = GET_PRIV (mallard);
- MallardPageData *page_data;
+ MallardPageData *page_data = NULL;
+ gchar *real_id = NULL;
GError *error;
- page_data = g_hash_table_lookup (priv->pages_hash, page_id);
+ debug_print (DB_FUNCTION, "entering\n");
+ debug_print (DB_ARG, " page_id=\"%s\"\n", page_id);
+
+ if (page_id != NULL)
+ real_id = yelp_document_get_page_id ((YelpDocument *) mallard, page_id);
+
+ if (real_id != NULL) {
+ page_data = g_hash_table_lookup (priv->pages_hash, page_id);
+ g_free (real_id);
+ }
+
if (page_data == NULL) {
gchar *docuri = yelp_uri_get_document_uri (priv->uri);
error = g_error_new (YELP_ERROR, YELP_ERROR_NOT_FOUND,
@@ -358,6 +367,7 @@ mallard_try_run (YelpMallardDocument *mallard,
yelp_document_signal ((YelpDocument *) mallard, page_id,
YELP_DOCUMENT_SIGNAL_ERROR,
error);
+ g_error_free (error);
return;
}
diff --git a/libyelp/yelp-transform.c b/libyelp/yelp-transform.c
index 3b04635..abf77ac 100644
--- a/libyelp/yelp-transform.c
+++ b/libyelp/yelp-transform.c
@@ -26,6 +26,7 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <glib-object.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xinclude.h>
diff --git a/libyelp/yelp-transform.h b/libyelp/yelp-transform.h
index f0376c2..dfef354 100644
--- a/libyelp/yelp-transform.h
+++ b/libyelp/yelp-transform.h
@@ -24,6 +24,7 @@
#define __YELP_TRANSFORM_H__
#include <glib.h>
+#include <glib-object.h>
#include <libxml/tree.h>
#include <libxslt/xslt.h>
#include <libxslt/transform.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]