aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-folder-search.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2001-01-23 12:37:59 +0800
committerMichael Zucci <zucchi@src.gnome.org>2001-01-23 12:37:59 +0800
commit4cf9b5a00cb088a3d40974f48b69120afcaf1b68 (patch)
treeaf8502deb7d160d121e63bb2e5de2b5671f89850 /camel/camel-folder-search.c
parent73053088aa1a33486a1bfb9637bf37f8bf984a18 (diff)
downloadgsoc2013-evolution-4cf9b5a00cb088a3d40974f48b69120afcaf1b68.tar.gz
gsoc2013-evolution-4cf9b5a00cb088a3d40974f48b69120afcaf1b68.tar.zst
gsoc2013-evolution-4cf9b5a00cb088a3d40974f48b69120afcaf1b68.zip
Perform error checking on parsing/execution.
2001-01-23 Not Zed <NotZed@Ximian.com> * camel-filter-search.c (camel_filter_search_match): Perform error checking on parsing/execution. * camel-folder-search.c (camel_folder_search_execute_expression): Perform error handling on search expression. (CamelFolderSearchPrivate): Add a camelexception for error returns. (camel_folder_search_execute_expression): Setup exception pointer. (search_match_all): Quit on error. * providers/imap/camel-imap-summary.c (message_info_load): Removed some debug 'warnings', as they should now be displayed at the toplevel loader, and just made the code match similar code elsewhere. * providers/local/camel-mbox-summary.c (message_info_load): Error handling. (message_info_save): more error handling. * camel-folder-summary.c (message_info_load): Add error handling and sanity checking. (camel_folder_summary_load): Add error checks. (perform_content_info_load): Error + sanity checks. (content_info_load): error + sanity checks. svn path=/trunk/; revision=7739
Diffstat (limited to 'camel/camel-folder-search.c')
-rw-r--r--camel/camel-folder-search.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/camel/camel-folder-search.c b/camel/camel-folder-search.c
index c1023b5f41..45409de3c9 100644
--- a/camel/camel-folder-search.c
+++ b/camel/camel-folder-search.c
@@ -47,6 +47,7 @@
struct _CamelFolderSearchPrivate {
GHashTable *mempool_hash;
+ CamelException *ex;
};
#define _PRIVATE(o) (((CamelFolderSearch *)(o))->priv)
@@ -304,21 +305,34 @@ GPtrArray *
camel_folder_search_execute_expression(CamelFolderSearch *search, const char *expr, CamelException *ex)
{
ESExpResult *r;
- GPtrArray *matches = g_ptr_array_new ();
+ GPtrArray *matches;
int i;
GHashTable *results;
EMemPool *pool;
struct _CamelFolderSearchPrivate *p = _PRIVATE(search);
+ p->ex = ex;
+
/* only re-parse if the search has changed */
if (search->last_search == NULL
|| strcmp(search->last_search, expr)) {
e_sexp_input_text(search->sexp, expr, strlen(expr));
- e_sexp_parse(search->sexp);
+ if (e_sexp_parse(search->sexp) == -1) {
+ camel_exception_setv(ex, 1, _("Cannot parse search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ return NULL;
+ }
+
g_free(search->last_search);
search->last_search = g_strdup(expr);
}
r = e_sexp_eval(search->sexp);
+ if (r == NULL) {
+ if (!camel_exception_is_set(ex))
+ camel_exception_setv(ex, 1, _("Error executing search expression: %s:\n%s"), e_sexp_error(search->sexp), expr);
+ return NULL;
+ }
+
+ matches = g_ptr_array_new();
/* now create a folder summary to return?? */
if (r
@@ -459,6 +473,7 @@ search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFold
g_ptr_array_add(r->value.ptrarray, (char *)camel_message_info_uid(search->current));
} else {
g_warning("invalid syntax, matches require a single bool result");
+ e_sexp_fatal_error(f, _("(match-all) requires a single bool result"));
}
e_sexp_result_free(r1);
} else {
@@ -472,6 +487,7 @@ search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFold
if (search->summary == NULL) {
/* TODO: make it work - e.g. use the folder and so forth for a slower search */
g_warning("No summary supplied, match-all doesn't work with no summary");
+ g_assert(0);
return r;
}
@@ -485,6 +501,7 @@ search_match_all(struct _ESExp *f, int argc, struct _ESExpTerm **argv, CamelFold
g_ptr_array_add(r->value.ptrarray, (char *)camel_message_info_uid(search->current));
} else {
g_warning("invalid syntax, matches require a single bool result");
+ e_sexp_fatal_error(f, _("(match-all) requires a single bool result"));
}
e_sexp_result_free(r1);
} else {